Mark Gillespie wrote:

> My webpage works fine under IE4/5, but there is some simple javascript that
> does not work (at all) under NS6.2 (havn't tried NS4.x, as I don't have it
> loaded)

The problem is the way you refer to the 'mytext' element. Simply saying

mytext.innerHTML = "Home."

isn't good enough. The correct way to get an element is by using 
getElementById - like this:

document.getElementById("mytext").innerHTML = "Home."

This will work all browsers that implement the W3C Document Object Model 
(http://www.w3.org/DOM/) correctly, such as Mozilla/Netscape 6 and IE 5 
and newer. It won't work in IE 4, but nobody uses it anymore.

Although Mozilla/Netscape 6 does support innerHTML, it is not part of 
the official W3C DOM specification, so you shouldn't use it. The correct 
way of modifying the contents of an element is like this:

document.getElementById("mytext").childNodes[0].nodeValue = "Home.";

In order for that to work, the 'mytext' element must not be empty, so 
you must replace

<p id=mytext> </p>

with

<p id=mytext>&nbsp;</p>

Hope this helps!

-- 

/Jonas


Reply via email to