this javascript won't work in Firefox

Discussion in 'Javascript' started by LRW, Dec 3, 2004.

  1. LRW

    LRW Guest

    (Sorry if this is a repost...my newsreader keeps crashing on the
    posting--I don't know if the message going out or not)

    For some reason this javascript just won't work in Firefox. It works
    fine in
    IE, though.
    I know, IE is a bit more permissive than IE, and sometimes lets errors
    work
    when they shouldn't. But from what I can see, I just don't see what's
    wrong.
    I must have SOMETHING wrong, but I don't see what.

    I know the page does have some HTML 4 errors. The W3C validation erros
    though aren't anything that should be affecting javascript, however.

    Could someone give me a clue what might be preventing this from
    working?

    Oh, it's the toggling the display block/none at the bottom of the
    page.
    Here's the URL, and I'll also paste the relevant code below too.

    Thanks!
    Liam

    http://gto.ie-studios.net/item.php?itemid=3


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Games To Order - Your online discount superstore for all your
    gaming
    needs</title>
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1">
    <script language="JavaScript" type="text/JavaScript">
    <!--\ function make_vis(e)
    {
    var WX = e;
    if (WX=="d")
    {
    subtbl_desc.style.display = "block";
    } else {
    subtbl_desc.style.display = "none";
    }
    if (WX=="r")
    {
    subtbl_rev.style.display = "block";
    } else {
    subtbl_rev.style.display = "none";
    }
    if (WX=="s")
    {
    subtbl_stuff.style.display = "block";
    } else {
    subtbl_stuff.style.display = "none";
    }
    } //-->
    </script>--snip--<table><tr><td> <div id="subtbl_desc"
    style="display:block"
    align="left"> <table width="100%"> <tr> <td width="100%">
    TEXT 1 HERE </td>
    </tr> </table>
    </div>
    <div id="subtbl_rev" style="display:none" align="left">
    <table> <tr> <td>
    TEXT 2 HERE </td> </tr> </table>
    </div>
    <div id="subtbl_stuff" style="display:none" align="left">
    <table> <tr> <td>
    TEXT 3 HERE </td> </tr> </table>
    </div></td>
    </tr>
    </table>
    LRW, Dec 3, 2004
    #1
    1. Advertising

  2. In article <>,
    says...
    > (Sorry if this is a repost...my newsreader keeps crashing on the
    > posting--I don't know if the message going out or not)
    >
    > For some reason this javascript just won't work in Firefox. It works
    > fine in
    > IE, though.


    It's probably because Firefox can't find an object called "subtbl_desc".
    Look in Firefox's JavaScript Console (Tools menu), then look up
    getElementById().

    --
    Hywel http://kibo.org.uk/
    I do not eat quiche.
    Hywel Jenkins, Dec 3, 2004
    #2
    1. Advertising

  3. LRW

    LRW Guest

    Hywel Jenkins <> wrote in message news:<>...
    > In article <>,
    > says...
    > > (Sorry if this is a repost...my newsreader keeps crashing on the
    > > posting--I don't know if the message going out or not)
    > >
    > > For some reason this javascript just won't work in Firefox. It works
    > > fine in
    > > IE, though.

    >
    > It's probably because Firefox can't find an object called "subtbl_desc".
    > Look in Firefox's JavaScript Console (Tools menu), then look up
    > getElementById().


    Thanks! That was absolutely it. (Wait, I see now another problem. See
    end.)
    I changed it to this (for the benefit of any other clueless fellow
    like myself) and it works fine:

    function make_vis(e)
    {
    var WX = e;
    if (WX=="d")
    {
    document.getElementById("subtbl_desc").style.display = "block";
    } else {
    document.getElementById("subtbl_desc").style.display = "none";
    }
    if (WX=="r")
    {
    document.getElementById("subtbl_rev").style.display = "block";
    } else {
    document.getElementById("subtbl_rev").style.display = "none";
    }
    if (WX=="s")
    {
    document.getElementById("subtbl_stuff").style.display = "block";
    } else {
    document.getElementById("subtbl_stuff").style.display = "none";
    }
    }

    I used the Firefox JavaScript console, and while the script now works
    fine, I'm STILL getting a huge list of:
    Error: subtbl_desc is not defined
    Source File: http://gto.ie-studios.net/item.php?itemid=1
    Line: 54

    I don't get it. I read about getElementById() (as evidenced by the
    fact my changes work) and all I've seen have to do exactly with what
    I've changed in my code.
    I don't get what's still wrong. =/

    Thanks for your advice! I'm glad it helped me get it working, and I'd
    like to just leave it at that, but the additional warnings bug me and
    it's only professional that I deal with them even though there's no
    obvious effect on the site.

    Thanks,
    Liam
    LRW, Dec 3, 2004
    #3
  4. LRW

    Danny@Kendal Guest

    "LRW" <> wrote in message
    news:...
    > Hywel Jenkins <> wrote in message

    news:<>...
    > > In article <>,
    > > says...
    > > > (Sorry if this is a repost...my newsreader keeps crashing on the
    > > > posting--I don't know if the message going out or not)
    > > >
    > > > For some reason this javascript just won't work in Firefox. It works
    > > > fine in
    > > > IE, though.

    > >
    > > It's probably because Firefox can't find an object called "subtbl_desc".
    > > Look in Firefox's JavaScript Console (Tools menu), then look up
    > > getElementById().

    >
    > Thanks! That was absolutely it. (Wait, I see now another problem. See
    > end.)
    > I changed it to this (for the benefit of any other clueless fellow
    > like myself) and it works fine:



    > I used the Firefox JavaScript console, and while the script now works
    > fine, I'm STILL getting a huge list of:
    > Error: subtbl_desc is not defined
    > Source File: http://gto.ie-studios.net/item.php?itemid=1
    > Line: 54


    Are these *new* error messages or are they the old ones still in the
    javascript console logs?

    I tried your page in Firefox1.0, Opera7.54, IE6 and Mozilla1.7.3
    No javascript errors showing here. Have you already fixed the problem?
    My OS is WindowsXPpro(sp1), in case that makes a difference.
    Danny@Kendal, Dec 3, 2004
    #4
  5. LRW

    LRW Guest

    "Danny@Kendal" <> wrote in message news:<>...
    > "LRW" <> wrote in message
    > > I used the Firefox JavaScript console, and while the script now works
    > > fine, I'm STILL getting a huge list of:
    > > Error: subtbl_desc is not defined
    > > Source File: http://gto.ie-studios.net/item.php?itemid=1
    > > Line: 54

    >
    > Are these *new* error messages or are they the old ones still in the
    > javascript console logs?
    >
    > I tried your page in Firefox1.0, Opera7.54, IE6 and Mozilla1.7.3
    > No javascript errors showing here. Have you already fixed the problem?
    > My OS is WindowsXPpro(sp1), in case that makes a difference.


    Grrflippingrr.
    I didn't know that when you open the JavascriptConsole it holds onto
    the previous messages. I flushed the errors and reloaded and it now
    only has one error.
    Some "syntax error" with a green arrow on the 6 of the URL:

    Error: syntax error
    Source File: javascript: http://gto.ie-studios.net/item.php?itemid=6
    Line: 1, Column: 43
    Source Code:
    http://gto.ie-studios.net/item.php?itemid=6

    No idea what that means. Syntax seems fine to me, but I've recently
    learned that half of what I learned in the late 90's on Web design has
    been depricated or changed drastically. =)

    Thanks!
    Liam
    LRW, Dec 3, 2004
    #5
  6. JRS: In article <>,
    dated Fri, 3 Dec 2004 08:48:31, seen in news:comp.lang.javascript, LRW
    <> posted :

    >if (WX=="d")
    >{
    > document.getElementById("subtbl_desc").style.display = "block";
    >} else {
    > document.getElementById("subtbl_desc").style.display = "none";
    >}


    Consider :-

    document.getElementById("subtbl_desc").style.display =
    WX=="d" ? "block" : "none"

    (it should not affect your problem, though)

    It's better not to use Tabs to structure-indent code in news posts; use
    two spaces instead.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
    <URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
    <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
    Dr John Stockton, Dec 3, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chad
    Replies:
    4
    Views:
    8,314
  2. Altman
    Replies:
    2
    Views:
    848
    Altman
    Feb 14, 2007
  3. Nathan Sokalski

    Why won't the following work in FireFox?

    Nathan Sokalski, Oct 17, 2007, in forum: ASP .Net
    Replies:
    11
    Views:
    2,033
    David Mark
    Oct 18, 2007
  4. LAshooter

    Javascript won't work in Firefox

    LAshooter, Jun 27, 2005, in forum: Javascript
    Replies:
    5
    Views:
    121
    Thomas 'PointedEars' Lahn
    Jul 15, 2005
  5. Igal

    javascript won't work with FireFox

    Igal, Jan 22, 2007, in forum: Javascript
    Replies:
    3
    Views:
    99
Loading...

Share This Page