View Full Version : Need Help Changing Text on NS4 using older DOM
09-25-2003, 08:49 PM
I have text that I am dynamically changing on a page. My problem is that I also need to be able to change this text on a NS4 browser as well.
I have got the dynamic change to work using the "document.getElementById()" now I am trying to perform the same change using the "document.layer". I have never worked with the older DOM stuff before, and have no idea even where to start.
Any help would be greatly appreciated.
====================================== CODE ======================================
if (document.getElementById) /* Used For IE5+ NS5+ Browsers */
document.getElementById('splashMessageLoopText').firstChild.nodeValue = splashmessageloop[loopNum]
else /* Used For NS4 Browser */
document.layers['splashMessageLoopText'].value = splashmessageloop[loopNum]
(text I am trying to change in the document)
<span id="splashMessageLoopText" class="typeblueheader">Please Wait While The Slot Is Created</span>
09-25-2003, 08:54 PM
09-26-2003, 12:22 AM
hey caclark, it's not 'older DOM stuff', it's 'MAJOR p.o.s. stuff' with more bugs than an ant farm on Jupiter. Won't crash, though (as long as you don't try writing to <ilayers> :eek: ) so, here's a sample. NS4 really requires pinpoint adjustments since the layout engine is older than Ronald Reagan (in layout engine years).
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
font: 200 18px tahoma;
var splashmessageloop = [
'what\\'s happening, baby?' ,
'gimme an F!' ,
'wassup wid dat?'
var n = 0;
function spit_it_out(id, loopNum)
var el = document.getElementById(id)
else if (document.layers)
var SPANlt = '<span class="typeblueheader">', SPANrt = '</span>';
document['NS_' + id].document.layers.document.write(SPANlt + splashmessageloop[loopNum] + SPANrt);
document['NS_' + id].document.layers.document.close();
<td id="splashMessageLoopText" height="24" class="typeblueheader">
<ilayer id="NS_splashMessageLoopText" width="400" height="22"><layer class="typeblueheader">Please Wait While The Slot Is Created</layer></ilayer>
<input type="button" value=" do it " onclick="spit_it_out('splashMessageLoopText', (n>2?(n=0):n++))">
09-26-2003, 06:49 AM
Cheesebag, sorry to break your bubble, but the problem lies in the use of .write. That's the culprit that sometimes crashes nn4.
09-26-2003, 08:31 AM
I never experienced NS4 crashes in using .write() methods in the layer object. Problem arises if you forgot to use .close().
09-26-2003, 03:04 PM
Well, that too. The problem I was referring to lies in that nn4 is somewhat selective in what it allows a rewrite to contain. For example you might find an attribute to be perfectly ok to use on one type of element, but on another type of element it brings the browser down. (It's too long since I worked on nn4 for me to be mo0re precise about exactly what this was about, but setting the style attribute to certain values were allowed in some cases, but not in others.)
09-26-2003, 06:13 PM
I can't quote the exact thing to avoid when writing content to Netscape 4 but it's definitely related to inline styles (styles referenced in style sheets are OK) and it'll crash the browser even on a static page so it's not specific to the use of .write in a layer.
I've called NS 4 a millstone around the necks of web developers for years. Caclark, I'm so sorry to hear that you can't drop that millstone yet.
09-26-2003, 11:51 PM
Cheesebag, sorry to break your bubble, but the problem lies in the use of .write.Bubble intact! I didn't mean to imply that Navigator had one bug - writing to an ilayer's document - and: avoid that, and you're home free. Just that the problem lies elsewhere, and layers can be written to reliably. I skipped the obligatory (to some) 'don't sipport this browser' lecture, as I too have dealt with clients/IT folks who aren't interested in my opinions on coverage. Sorry, but, among other things, I've written two (functioning) X-browser apis that handle NS4 competently - it used to be indispensable - and I've gotten used to seeing misinformation posted about this ua, particularly of the 'can't do that!' variety. I think I answered the above question. ;)
Just fyi, I fully concur that skipping support for this relic, or at most selectively serving generic pages, is the proper course.
09-27-2003, 12:22 AM
Well, the style attribute wasn't the only attribute that this happened on. It happened on other attributes as well...
09-27-2003, 12:23 AM
Dan Steinman was always the authoritative source for DHTML in netscape 4 - http://www.dansteinman.com/dynduo/
09-27-2003, 12:35 AM
Dan Steinman, definately. :cool: Helped many in this regard. The other inspiration, speaking personally, was Scott Isaacs, MSIE lead developer, whose dhtmllib (http://www.insidedhtml.com/dhtmllib/page3.asp) shredded the NS4 DOM and rebuilt it - largely successfully - in the image of IE4's. Navigator with innerHTML, an all collection (more or less), event bubbling - amazing.