this javascript won't work in Firefox

L

LRW

(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>
 
H

Hywel Jenkins

(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().
 
L

LRW

Hywel Jenkins said:
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
 
D

Danny@Kendal

LRW said:
Hywel Jenkins <[email protected]> wrote in message

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.
 
L

LRW

Danny@Kendal said:
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
 
D

Dr John Stockton

JRS: In article <[email protected]>,
dated Fri, 3 Dec 2004 08:48:31, seen in LRW
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top