Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Oct 2002
    Location
    Setting in a tall corn field in Indiana
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need Help Changing Text on NS4 using older DOM

    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]
    }


    ...<snip>


    (text I am trying to change in the document)

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

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

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeň, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    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?)
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    Regular Coder
    Join Date
    Aug 2003
    Posts
    383
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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> ) so, here's a sample. NS4 really requires pinpoint adjustments since the layout engine is older than Ronald Reagan (in layout engine years).
    Code:
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" 
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    <head>
    <title>untitled</title>
    <style type="text/css">
    
    .typeblueheader {
                     font: 200 18px tahoma;
                     color: ghostwhite;
                     background: steelblue;
                     text-align: center;
                    }
    
    </style>
    <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())
    		{
    			el.removeChild(el.lastChild);
    		}
    		el.appendChild(document.createTextNode(splashmessageloop[loopNum]));
    	}
    	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();
    	}
    }
    
    </script>
    </head>
    <body style="background:ivory;">
    <table width="100%">
    <tr>
    <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>
    </td>
    </tr>
    </table>
    <br>
    <form>
    <input type="button" value=" do it " onclick="spit_it_out('splashMessageLoopText', (n>2?(n=0):n++))">
    </form>
    </body>
    </html>
    
    Last edited by cheesebag; 09-26-2003 at 12:25 AM.
    &nbsp;........ another wild guess ........

  • #4
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeň, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Cheesebag, sorry to break your bubble, but the problem lies in the use of .write. That's the culprit that sometimes crashes nn4.

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    I never experienced NS4 crashes in using .write() methods in the layer object. Problem arises if you forgot to use .close().

  • #6
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeň, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    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.)
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #8
    Regular Coder
    Join Date
    Aug 2003
    Posts
    383
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    &nbsp;........ another wild guess ........

  • #9
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeň, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Well, the style attribute wasn't the only attribute that this happened on. It happened on other attributes as well...
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #10
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Dan Steinman was always the authoritative source for DHTML in netscape 4 - http://www.dansteinman.com/dynduo/
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #11
    Regular Coder
    Join Date
    Aug 2003
    Posts
    383
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Dan Steinman, definately. Helped many in this regard. The other inspiration, speaking personally, was Scott Isaacs, MSIE lead developer, whose dhtmllib 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.
    &nbsp;........ another wild guess ........


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •