SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jul 2004
    Location
    London Ontario
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Not working in Firefox

    I have this script for a radio station and It works in ie but not firefox.
    The errors in the javascript console are as follows...

    Error: program is not defined (line 87)

    Error: syntax error (line 20)
    else if (day == 0 && time == 18)
    (and it has an arrow pointing to else if)

    Heres my javascript code... (the line 87 (in the html file) is just two script tags with a document.write(program); in it.



    function startplayer()
    {
    window.open('radio.htm','','width=380,height=203');
    };
    TTRprograms = new Date();
    var offair = 0;
    var time = TTRprograms.getHours();
    var day = TTRprograms.getDay();
    var program;
    if (offair != 0)
    {
    program = "station offline<BR>&nbsp;";
    };
    else if (day == 0 && time == 18)
    {
    program = "tech talk sundays<BR>&nbsp;&nbsp;<A href='#' onclick='startplayer()' style='text-decoration:none'><FONT color='#FF8000'>click Here to TUNE IN</FONT></A>";
    };
    else if (time < 19 && time > 5)
    {
    program = "tech music days<BR>&nbsp;&nbsp;<A href='#' onclick='startplayer()' style='text-decoration:none'><FONT color='#FF8000'>click Here to TUNE IN</FONT></A>";
    };
    else
    {
    program = "tech music nights<BR>&nbsp;&nbsp;<A href='#' onclick='startplayer()' style='text-decoration:none'><FONT color='#FF8000'>click Here to TUNE IN</FONT></A>";
    };

  2. #2
    SitePoint Wizard silver trophy KLB's Avatar
    Join Date
    Nov 2003
    Location
    Maine USA
    Posts
    3,781
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I believe you will find that your problem are the semi-colon after the closing French braces. Instead of '};' use '}' only.

    Also an observation: Get rid of the font tags and change the style to: "style='text-decoration:none;color:#FF8000'.
    Ken Barbalace: EnvironmentalChemistry.com (Blog, Careers)
    InternetSAR.org
    Volunteers Assist Search and Rescue via Internet
    My Firefox Theme: Classic Compact
    Based onFirefox's default theme but uses much less window space

  3. #3
    SitePoint Member
    Join Date
    Jul 2004
    Location
    London Ontario
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks! It worked!

    I was always told to use semicolons after those, but I guess I won't from now on since I have switched over to using Firefox.

    Thanks!

  4. #4
    SitePoint Zealot gohankid77's Avatar
    Join Date
    Jun 2004
    Location
    United States
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes. I'm surprised I didn't see that. When using { and }, any ";" should be inside.
    Gohan (Mmm... Yummy!)

  5. #5
    SitePoint Wizard silver trophy KLB's Avatar
    Join Date
    Nov 2003
    Location
    Maine USA
    Posts
    3,781
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The reason that the semi-colon didn't work is because if(){}else{} is essentially one instruction. The semi-colon broke this up.
    Ken Barbalace: EnvironmentalChemistry.com (Blog, Careers)
    InternetSAR.org
    Volunteers Assist Search and Rescue via Internet
    My Firefox Theme: Classic Compact
    Based onFirefox's default theme but uses much less window space

  6. #6
    SitePoint Zealot gohankid77's Avatar
    Join Date
    Jun 2004
    Location
    United States
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That is why KLB is a SitePoint Guru
    Gohan (Mmm... Yummy!)


Bookmarks

Posting Permissions

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