< cross browser >
Creating a "cross-browser" layer
<div id="crosslayer" style="position:absolute"></div>
NS 4 treats the above div exactly the same as it would with a layer. Like any other layer, to access it , we would first go go through the document object, then the layer's id:
In IE 4, we would simply use the div's id:
I found that in NS, specifying a layer this way, while convenient in terms of cross-browser compatibility, has one major draw back. Such a layer doesn't always behave the way a normal layer should, and can sometimes actually crash the browser. Just be prepared to expect the unexpected!Browser sniffing, object detection
var ns4= (navigator.appName== "Netscape"&&navigator.appVersion>=4)
Personally, I hate using the navigator object- its so complicated to use (just look at the above mess!). Well, I have good news to bring to you. There is actually a lot quicker way to sniff out various browsers, and its called object detection.
Translating the above into English, it reads: "If the browser supports the images object (which only NS 3+ and IE 4+ do), alert a message.
Now you never have to return to the messy navigator object to do your browser sniffings!
This tutorial is written and contributed by David Gardner.
Help promote this site