Following is a script scrap that demonstrates how to avoid this:
On Internet Explorer 5, defining a layer (<DIV id="myID">, <SPAN id="myID">) without including an inline style sheet reference for its position, style="left:xx;top:yy;", causes the DOM2 style sheet reference document.getElementById(id) method to fail. This problem did not exhibit itself using Netscape 6.
Since discovering this problem, Iíve upgraded to Internet Explorer 6 and discovered that this problem no longer exists, and since Microsoft doesnít allow more than one Internet Explorer version on a system, I was not able to reconfirm the existence of this problem when writing this article. Suffice it to say, itís probably a good idea to include a style sheet position reference if planning on reliably using the document.getElementById(id) method.
While Netscape 4 supports the use of both the <DIV> and <SPAN> tags for creating containers (layers), along with the inclusion of the inline style attribute for positioning, I was unable to get DHTML (moving elements) to work when using either of them. Either of these two methods is a standard way to create containers (layers) in both Netscape 6 and Internet Explorer 4/5/6. To make matters worse, every attempt to do so not only caused the browser to hang but also left a hidden Netscape 4 window running in the background (not even detectable via Windows Task Manager) that prevented Netscape 4 from restarting clean afterwards. After this occurred, the only way to restore Netscape 4 was to terminate the hidden Netscape 4 window using a system utility (not many people have these) or to restart Windows.
So, if you plan on creating DHTML using either <DIV> or <SPAN> tags, it is wise to test for the existence of Netscape 4 before attempting to manipulate their style sheet properties. If itís the client browser, either skip the DHTML manipulation or add Netscape 4-specific HTML tag, <LAYER>, and manipulate its style sheet properties.
YAMF - "Yet Another Mouse Follower"
All Is Not What It Seems
Netscape 6 Made Me Do It!
Testing - To Reload or To Restart?
Browser Sniffing - Parse or Presence?
Stopping Annoying Auto-Scroll in DOM2 Browsers
Netscape 6 is Pixel Picky
Inline Style Constraint on Internet Explorer 5
Must Use <LAYER> tag in Netscape 4 to perform DHTML
!DOCTYPE Compliance Mode
Take Care Not to Render in <HEAD> Section
Automatic Expansion of Relative URLs
The Elusive Netscape 4 Layer Elements
Temperamental onLoad After Reload
document.images[id].complete Property Dependency
Search Method Does Not Return Boolean Value
Regular Expression Global Flag Fails With Subsequent Usage
Roll Your Own
|Copyright © 2002-2003, ProjectIt, All Rights Reserved||Last Revised:|