View Full Version : Need Help Changing Text on NS4 using older DOM

09-25-2003, 09: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)

<table width="100%">
<td width="30%"></td>

<td align="left">
<span id="splashMessageLoopText" class="typeblueheader">Please Wait While The Slot Is Created</span>

09-25-2003, 09:54 PM
In nn4, only layer/ilayer tags, or positioned div tags, can be reached into and changed, and changing them is a process that often crashes the browser. I'd create an alternate version for nn4 that doesn't require dynamic changes to occur instead, or hand it the unstyled/javascriptless version with it's jump-past-this link. (You do have a such, don't you?)

09-26-2003, 01: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"

<style type="text/css">

.typeblueheader {
font: 200 18px tahoma;
color: ghostwhite;
background: steelblue;
text-align: center;

<script type="text/javascript" language="javascript">

var splashmessageloop = [
'what\\'s happening, baby?' ,
'gimme an F!' ,
'wassup wid dat?'

var n = 0;

function spit_it_out(id, loopNum)
if (document.getElementById)
var el = document.getElementById(id)
while (el.hasChildNodes())
else if (document.layers)
var SPANlt = '<span class="typeblueheader">', SPANrt = '</span>';
document['NS_' + id].document.layers[0].document.write(SPANlt + splashmessageloop[loopNum] + SPANrt);
document['NS_' + id].document.layers[0].document.close();

<body style="background:ivory;">
<table width="100%">
<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, 07: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, 09: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, 04: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.)

Roy Sinclair
09-26-2003, 07: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-27-2003, 12:51 AM
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, 01: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, 01:23 AM
Dan Steinman was always the authoritative source for DHTML in netscape 4 - http://www.dansteinman.com/dynduo/

09-27-2003, 01: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.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum