Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML JavaScript

Browser related scrpts

Javascript coding ..

Moderators: macek, egami, gesf

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.
sanketce
New php-forum User
New php-forum User
 
Posts: 90
Joined: Fri Dec 02, 2005 3:23 am

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.
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

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

Thanks dear for kindly reply....
sanketce
New php-forum User
New php-forum User
 
Posts: 90
Joined: Fri Dec 02, 2005 3:23 am

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 :)
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden


Return to JavaScript

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.