...

View Full Version : Very simple script OK in IE, Opera; fails in FF



Roy Gardiner
01-27-2006, 10:19 AM
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?

glenngv
01-27-2006, 11:21 AM
document.getElementById("tbl")
That's the proper way to reference an element by id.
Always open the Javascript Console to easily spot the error.

Roy Gardiner
01-27-2006, 01:56 PM
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.

konithomimo
01-27-2006, 02:21 PM
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.

Bill Posters
01-27-2006, 03:42 PM
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?

Kor
01-27-2006, 03:57 PM
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)

glenngv
01-30-2006, 02:55 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum