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 7 of 7
  1. #1
    New Coder
    Join Date
    Jan 2004
    Location
    London, England
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Very simple script OK in IE, Opera; fails in FF

    Not sure if this is the right place for browser wars... ?

    http://www.roygardiner.com/test11.htm The buttons will turn off and back on the grid and the picture, leaving the little flashing imgs in place.

    In FF neither button does anything and the imgs are not placed inside the table cells but across lines.

    The table is fairly big, but the script is as simple as it's possible to get; am I making some basic FF environmental error, perhaps?

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Code:
    document.getElementById("tbl")
    That's the proper way to reference an element by id.
    Always open the Javascript Console to easily spot the error.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New Coder
    Join Date
    Jan 2004
    Location
    London, England
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by glenngv
    Code:
    document.getElementById("tbl")
    That's the proper way to reference an element by id.
    Always open the Javascript Console to easily spot the error.
    Thank you Glen.

    Hmm, is there an easy way of telling if what I am doing is non-standard? The way of referencing the elements (not the code itself) was copied, and I can't see any reason why it 'shouldn't' work that way.

  • #4
    New Coder
    Join Date
    Dec 2005
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Run your code through a validator. That will tell you what is wrong with it, or what you can add to it to make it work better.

  • #5
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by konithomimo
    Run your code through a validator. That will tell you what is wrong with it, or what you can add to it to make it work better.
    A js validator?

  • #6
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    try:

    document.getElementById('tbl').className
    instead of
    tbl.className

    and

    document.getElementById('mapimg').style.display
    instead of
    mapimg.style.display

    Elements should be referenced starting with their basement tree root (document this case), and their id or name or tagname (id -- getEelementById() in your case)
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Quote Originally Posted by Roy Gardiner
    Hmm, is there an easy way of telling if what I am doing is non-standard? The way of referencing the elements (not the code itself) was copied, and I can't see any reason why it 'shouldn't' work that way.
    You probably copied it in MSDN sample codes or IE-only web sites. Actually Firefox also supports referencing elements directly by id (probably for compatibility with IE-only sites) but only if no DOCTYPE is specified.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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