Cross Browser DOM Script
Join the Discussion
Related Tutorial
If you are creating your own dynamic HTML scripts then you will need to work out which document object model a given browser supports if your script is to function in that browser. All version 5+ browsers support the standard DOM but there may still sufficient visitors still using Netscape 4 to make it worth supporting that DOM as well. This code does that for you and also provides a function that you can call that will allow your script to work with whichever of the DOMs that the browser supports.
The code to support the Internet Explorer 4 DOM is commented out in the code as statistics I have seen suggest that no one uses that browserr any more. If your statistics show differently then uncomment the code, otherwise you can delete the /* */ commented code.
This code should be incorporated into a script in the head section of your page.
Once we have incorporated this code into our script we can then reference the objects on our page as follows. To reference the ordinary properties and methods (assuming we have labelled the object 'myobj'):
var myval = obj.value;
The only change we need to make to reference the style properties is to replace the 0 with a 1.
var mytop = objS.top;
For more information see the Cross Browser DOM tutorial.

