Bug 15127 - getElementById enhancement request
Summary: getElementById enhancement request
Status: RESOLVED DUPLICATE of bug 6006
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 523.x (Safari 3)
Hardware: Mac OS X 10.4
: P2 Minor
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-31 21:20 PDT by jason hu
Modified: 2007-11-07 13:03 PST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jason hu 2007-08-31 21:20:28 PDT
getElementById function retrieves element by the "id" attribute, but IE browser also checks "name" attribute too if the "id" doesn't exist. 
I noticed many web pages were code in the way, it calls "getElementById" and only "name" attribute exist for the element, 

so can you add this simple check if the "id" exist, use "id", otherwise use "name"?

thanks
Comment 1 Alexey Proskuryakov 2007-09-01 00:36:55 PDT
Could you please give examples of real sites coded this way?
Comment 2 mitz 2007-09-01 00:57:53 PDT
(In reply to comment #1)
> Could you please give examples of real sites coded this way?

The customer service section of the Israeli Orange franchise, <https://direct.orange.co.il/selfservice/>.
Comment 3 jason hu 2007-09-01 06:39:06 PDT
the reason why some sites are coded this way is because of some Web Framwork, such as "Struts" doesn't generate "id" attribute by default, but it generates "name" attribute all the time, and  getElementById works fine in IE even without "id" attribute, some lazy developers don't even bother to go back fix this.
Struts was so popular, I saw this problem since begining.
Comment 4 Alexey Proskuryakov 2007-10-05 04:35:34 PDT
Opera is apparently going to remove this quirk from their 9.50 release:

"Removed IE-compatibility where Document.getElementById treated name and id attributes the same, which caused problems with jQuery."

Still, this is a compatibility issue that we should consider fixing.
Comment 5 Alexey Proskuryakov 2007-11-07 13:03:10 PST

*** This bug has been marked as a duplicate of 6006 ***