Gossamer Forum
Home : General : Internet Technologies :

Firefox won't accept getElementById ?

Quote Reply
Firefox won't accept getElementById ?
Hi,

Got a problem with some javascript I've just written :(

It looks like;

Code:
<script language="JavaScript">
<!-- Begin
function docheck() {
var isIE = false;
var isNav = false;
if (navigator.appName == "Netscape") {
isNav = true
} else {
isIE = true
}

if (isIE) {
document.getElementById('loadingdiv').style.display = 'none';
document.getElementById('downloadit').style.display = 'block';
}

if (isNav) {
document.getElementById('loadingdiv').style.display = 'none';
document.getElementById('downloadit').style.display = 'block';
}

alert("Browser: " + navigator.appName);

}
// End -->
</script>
<body class="body_1col" onload="javascript: docheck()">

Basically, when the page loads... docheck() is run, and decides it its an IE or Mozilla browser.

This part works fine in IE... but not FireFox;

Code:
document.getElementById('loadingdiv').style.display = 'none';
document.getElementById('downloadit').style.display = 'block';

Anyone got any ideas? (I'm basically trying to make a "loading" div, which gets shown while the page loads, and then dissapears after its finished ... revealing the main div, which has the content in it :)).

TIA

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Firefox won't accept getElementById ? In reply to
*bump*

Unsure
Quote Reply
Re: [Andy] Firefox won't accept getElementById ? In reply to
Not sure if this is still a problem for you but I've found that Internet Explorer assumes the id to be the same as the name if id is not set. Firefox does no assumption. Assign an id to the elments that you are trying to work with and it should start working. I just ran across this the other day and plan to play around with it a little more. If your interested here is a link http://www.4webresources.com/...ry=20050923025356806. Hope this helps.