Primal-oooze said on 30/03/2006 3:24 PM AEST:
Thanks everyone,
I googled your suggestions and have a better idea now.
I haven't worked on this stuff for a few years and I hoped by now there would be some cross browser methods.
There are.
Oh well some things never change.
They have. Use W3C DOM methods, add support for version 4 browsers if
required.
In regard to the code you posted, it won't work because you are
attempting to access and modify elements before they are created. I
guess it was just an example and what you really wanted to know was how
to go about modifying the DOM.
In regard to the methods/properties in your posted code:
document.all is a Microsoft proprietary method that is not well
supported outside IE. It has been replaced almost completely by the DOM
compliant document.getElementById(), which works in IE 5 and later and
virtually all browsers since about 1998.
innerText is a Microsoft proprietary property, it is not well supported
by other browsers. The DOM compliant alternative is textContent.
Alternative functions that you may like to use (or not) are posted here:
<URL:
http://groups.google.co.uk/group/co...ifferences+IE/Firefox&rnum=1#23eaaa3cc6e036e9>
But generally there is little reason to use it when a text node will do
the job just as well.
innerHTML is a Microsoft proprietary property that has been widely
copied by other browsers. There is Mozilla extension (the range
interface) that provides the same functionality, but it's generally
simpler to just use innerHTML.