Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Daf
    Daf is offline
    Regular Coder
    Join Date
    Feb 2005
    Location
    East Texas
    Posts
    140
    Thanks
    32
    Thanked 2 Times in 2 Posts

    Missing Space Character Problem

    Okay - having a hard time with this one. ... getting validation error when trying to use below code. This code was sent to us by the stream hosting company - it opens a custom player. The validation error is:

    Is there a missing space character? A quoted string (like an attribute value) cannot be immediately followed by text.
    I'll be danged if I can figure out where the missing space is -

    Also - the validator is warning of using both onclick and a href - would someone be so kind as to advise a better way to write/code this action?

    Code:
    <h2><a href="javascript:{}"onclick="window.open('http://radio.securenetsystems.net/radio_player_large.cfm?stationCallSign=KTBB','radio_player','Width=822,Height=507,directories=0,hotkeys=0,location=0,menubar=0,personalbar=0,resizable=0,scrollbars=0,status=0,toolbar=0');">Listen To KTBB AM600 Live!</a></h2>
    Thanks!!
    Daf

  • #2
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,707
    Thanks
    0
    Thanked 237 Times in 232 Posts
    Hi there Daf,

    the code that you posted did validate, so the error
    must refer to something else in your code.

    Your link, as is, will not work for those users who happen
    to have javascript disabled.

    I would code it this...
    Code:
    
    <!DOCTYPE html>
    <html lang="en">
    <head>
    
    <meta charset="utf-8">
    
    <title>untitled document</title>
    
    <script>
    (function() {
       'use strict';
    
    function init(){ 
    
       var mywindow;
       var features='width=822,height=507';
    
    document.getElementById('ktbb').onclick=function() {
    
    if(mywindow) {
       mywindow.close();
     }
       mywindow=window.open(this.href,'radio_player',features);
       mywindow.focus();
       return false;
      }
    }
       window.addEventListener?
       window.addEventListener('load',init,false):
       window.attachEvent('onload',init);
    })();
    </script>
    
    </head>
    <body>
    
    <h2>
     <a id="ktbb" href="http://radio.securenetsystems.net/radio_player_large.cfm?stationCallSign=KTBB">
      Listen To KTBB AM600 Live!
     </a>
    </h2>
    
    </body>
    </html>
    coothead

  • Users who have thanked coothead for this post:

    Daf (08-15-2013)

  • #3
    Senior Coder
    Join Date
    Sep 2010
    Posts
    2,034
    Thanks
    15
    Thanked 240 Times in 240 Posts
    I see it right away.

    "onclick

    There should be a space between the double quote and the onclick.
    Welcome to http://www.myphotowizard.net

    where you can edit images, make a photo calendar, add text to images, and do much more.


    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development. And you can always charge more for Research and Development.

  • Users who have thanked DrDOS for this post:

    Daf (08-15-2013)

  • #4
    Daf
    Daf is offline
    Regular Coder
    Join Date
    Feb 2005
    Location
    East Texas
    Posts
    140
    Thanks
    32
    Thanked 2 Times in 2 Posts
    Thank you so much coothead! That works - makes the validator happy and works more effeciently, too!

    One additional question if you would please?

    I have links to a station with a player on the page twice - 2 stations/2 players - how do I modify the code in the head section to get the 2nd id in there? I tried

    Code:
    document.getElementById('ktbb', 'kyzs').onclick=function() {
    simply adding in the new id but that did not work - in that the kyzs link doesn't open the player - it does connect (which is good for those without JS) but no player.

    Thanks again!
    Daf

  • #5
    Daf
    Daf is offline
    Regular Coder
    Join Date
    Feb 2005
    Location
    East Texas
    Posts
    140
    Thanks
    32
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by DrDOS View Post
    I see it right away.

    "onclick

    There should be a space between the double quote and the onclick.
    Hi DrDOS

    Putting a space where you suggest still triggered the same error.

    Thanks!

  • #6
    Daf
    Daf is offline
    Regular Coder
    Join Date
    Feb 2005
    Location
    East Texas
    Posts
    140
    Thanks
    32
    Thanked 2 Times in 2 Posts
    Okay - I'm trying to figure this out but not having much luck. Since I will have 2 different ids (ktbb and kyzs) I needed to modify the JS in the head section. So instead of
    Code:
    document.getElementById('ktbb').onclick=function() {
    i tried

    Code:
    document.getElementByClassName('ktbb').onclick=function() {
    and
    Code:
    document.getElementByClassName("ktbb").onclick=function() {
    and changed the links to class="ktbb" ...

    but that didn't work.

    I have little to know JS skill and am properly stumped!

  • #7
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,707
    Thanks
    0
    Thanked 237 Times in 232 Posts
    Hi there Daf,

    here you go...
    Code:
    
    <!DOCTYPE html>
    <html lang="en">
    <head>
    
    <meta charset="utf-8">
    
    <title>untitled document</title>
    
    <script>
    (function() {
       'use strict';
    
    function init(){ 
    
       var mywindow;
       var anc=document.getElementsByTagName('a');
       var c=anc.length;
    while(--c>-1) {
    
       anc[c].onclick=function(){
    
    if(mywindow) {
       mywindow.close();
     }
    if(this.className.match('popup')) {
       var w=this.getAttribute('data-dimensions').split(',')[0];
       var h=this.getAttribute('data-dimensions').split(',')[1];
       var l=(screen.width-w)/2;
       var t=(screen.height-h)/2;
       var features='width='+w+',height='+h+',left='+l+',top='+t;
       mywindow=window.open(this.href,'radio_player',features);
       mywindow.focus();
       return false;
        }
       }
      }
     }
       window.addEventListener?
       window.addEventListener('load',init,false):
       window.attachEvent('onload',init);
    })();
    </script>
    
    </head>
    <body>
    
    <h2>
     <a class="popup" data-dimensions="822,507" href="http://radio.securenetsystems.net/radio_player_large.cfm?stationCallSign=KTBB">
      Listen To KTBB AM600 Live!
     </a>
    </h2>
    
    <h2>
     <a class="popup" data-dimensions="822,507" href="http://radio.securenetsystems.net/radio_player_large.cfm?stationCallSign=KYZS">
      Listen To KYZS AM1490 Live!
     </a>
    </h2>
    
    </body>
    </html>
    coothead
    Last edited by coothead; 08-15-2013 at 03:44 PM.

  • Users who have thanked coothead for this post:

    Daf (08-15-2013)

  • #8
    Daf
    Daf is offline
    Regular Coder
    Join Date
    Feb 2005
    Location
    East Texas
    Posts
    140
    Thanks
    32
    Thanked 2 Times in 2 Posts
    Incredible! That works perfectly!! Thank you so much for all your help!

  • #9
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,707
    Thanks
    0
    Thanked 237 Times in 232 Posts

    No problem, you're very welcome.

    coothead


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •