Browser related scrpts

Javascript coding ..

Moderators: macek, egami, gesf

sanketce
New php-forum User
New php-forum User
Posts: 90
Joined: Fri Dec 02, 2005 3:23 am

Browser related scrpts

Postby sanketce » Tue Jan 17, 2006 12:42 am

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.

User avatar
gesf
Moderator
Moderator
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Postby gesf » Tue Jan 17, 2006 3:33 am

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.

sanketce
New php-forum User
New php-forum User
Posts: 90
Joined: Fri Dec 02, 2005 3:23 am

Postby sanketce » Tue Jan 17, 2006 4:03 am

Thanks dear for kindly reply....

User avatar
gesf
Moderator
Moderator
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Postby gesf » Wed Jan 18, 2006 11:55 am

Any time :) I think i already "said", but... don't use document.all. Forget it, it's deprecated :)


Return to “JavaScript”

Who is online

Users browsing this forum: No registered users and 1 guest

cron