Browser related scrpts

A

Anonymous

Guest
Hi,

I am searching one common code for all the browsers i.e. IE, FireFox, and Netscape

for example: we can refer any object by its id in javascript by 2 ways

1. document.all
2. document.getElementById

but these 2 are not working in all listed above browsers rather work browser specific, one works in firefox one works in netscape... etc.

so how can I refer any object by its id in javascript and it must work in all given browsers.

I want one line to refer object by its id and It should also work in 3 browsers.
 
document.all was introduced in Internet Explorer 4, because the W3C DOM hadn't yet standardised a way of grabbing references to elements using their IDs. By the time IE 5 came out, document.getElementById() had been standardised and as a result, IE 5 included support for it. IE 5 was released in September 1998, so i can tell you that document.getElementById() is supported by every Javascript supporting browser released since 1998.
I believe that, sometimes and in sames cases, you must add the window. in fron of if.
 
Any time :) I think i already "said", but... don't use document.all. Forget it, it's deprecated :)
 
Back
Top