this javascript won't work in Firefox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • LRW

    this javascript won't work in Firefox

    (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




    <!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="JavaS cript" type="text/JavaScript">
    <!--\ function make_vis(e)
    {
    var WX = e;
    if (WX=="d")
    {
    subtbl_desc.sty le.display = "block";
    } else {
    subtbl_desc.sty le.display = "none";
    }
    if (WX=="r")
    {
    subtbl_rev.styl e.display = "block";
    } else {
    subtbl_rev.styl e.display = "none";
    }
    if (WX=="s")
    {
    subtbl_stuff.st yle.display = "block";
    } else {
    subtbl_stuff.st yle.display = "none";
    }
    } //-->
    </script>--snip--<table><tr><t d> <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_stuf f" style="display: none" align="left">
    <table> <tr> <td>
    TEXT 3 HERE </td> </tr> </table>
    </div></td>
    </tr>
    </table>
  • Hywel Jenkins

    #2
    Re: this javascript won't work in Firefox

    In article <37a6c958.04120 22246.5a283ac1@ posting.google. com>,
    news@celticbear .com says...[color=blue]
    > (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.[/color]

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

    --
    Hywel http://kibo.org.uk/
    I do not eat quiche.

    Comment

    • LRW

      #3
      Re: this javascript won't work in Firefox

      Hywel Jenkins <hyweljenkins@h otmail.com> wrote in message news:<MPG.1c1a1 d94836e7a599896 a9@news.individ ual.net>...[color=blue]
      > In article <37a6c958.04120 22246.5a283ac1@ posting.google. com>,
      > news@celticbear .com says...[color=green]
      > > (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.[/color]
      >
      > It's probably because Firefox can't find an object called "subtbl_des c".
      > Look in Firefox's JavaScript Console (Tools menu), then look up
      > getElementById( ).[/color]

      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.getEle mentById("subtb l_desc").style. display = "block";
      } else {
      document.getEle mentById("subtb l_desc").style. display = "none";
      }
      if (WX=="r")
      {
      document.getEle mentById("subtb l_rev").style.d isplay = "block";
      } else {
      document.getEle mentById("subtb l_rev").style.d isplay = "none";
      }
      if (WX=="s")
      {
      document.getEle mentById("subtb l_stuff").style .display = "block";
      } else {
      document.getEle mentById("subtb l_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

      Comment

      • Danny@Kendal

        #4
        Re: this javascript won't work in Firefox

        "LRW" <news@celticbea r.com> wrote in message
        news:37a6c958.0 412030848.7d95c a22@posting.goo gle.com...[color=blue]
        > Hywel Jenkins <hyweljenkins@h otmail.com> wrote in message[/color]
        news:<MPG.1c1a1 d94836e7a599896 a9@news.individ ual.net>...[color=blue][color=green]
        > > In article <37a6c958.04120 22246.5a283ac1@ posting.google. com>,
        > > news@celticbear .com says...[color=darkred]
        > > > (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.[/color]
        > >
        > > It's probably because Firefox can't find an object called "subtbl_des c".
        > > Look in Firefox's JavaScript Console (Tools menu), then look up
        > > getElementById( ).[/color]
        >
        > 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:[/color]

        [color=blue]
        > 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[/color]

        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(sp 1), in case that makes a difference.


        Comment

        • LRW

          #5
          Re: this javascript won't work in Firefox

          "Danny@Kend al" <danny@STOPSPAM ghpkendal.co.uk > wrote in message news:<prWdnQ207 sanPS3cRVnyvQ@e clipse.net.uk>. ..[color=blue]
          > "LRW" <news@celticbea r.com> wrote in message[color=green]
          > > 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[/color]
          >
          > 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(sp 1), in case that makes a difference.[/color]

          Grrflippingrr.
          I didn't know that when you open the JavascriptConso le 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:


          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

          Comment

          • Dr John Stockton

            #6
            Re: this javascript won't work in Firefox

            JRS: In article <37a6c958.04120 30848.7d95ca22@ posting.google. com>,
            dated Fri, 3 Dec 2004 08:48:31, seen in news:comp.lang. javascript, LRW
            <news@celticbea r.com> posted :
            [color=blue]
            >if (WX=="d")
            >{
            > document.getEle mentById("subtb l_desc").style. display = "block";
            >} else {
            > document.getEle mentById("subtb l_desc").style. display = "none";
            >}[/color]

            Consider :-

            document.getEle mentById("subtb l_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.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
            <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
            <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

            Comment

            Working...