Cvermule

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Monday, 7 August 2006

IE Bug Using document.getElementById()

Posted on 12:33 by Unknown
If you are using either document.getElementById() or prototype's $() and you have an element in your page with it's name that is the same as the id of an element that comes after it, DON'T DO IT!!!

IE treats the id and name attributes of elements equally when using document.getElementById().

For an example, use the following HTML code.


<html>
<body>
name: testMe
<input type="text" name="testMe" value="First Element" /><br />
name: dontTestMe id: testMe
<input type="text" name="dontTestMe" id="testMe" value="Second Element" />
<br />
<input type="button" onclick="alert(document.getElementById('testMe').value);" value="Click me to see what happens." " />
</body>
</html>


Working Example


name: testMe


name: dontTestMe id: testMe



Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in browser specific, coding, example, web development | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

Categories

  • amazon
  • browser specific
  • coding
  • Eclipse
  • error
  • example
  • funny
  • google
  • grep
  • hacks
  • javascript
  • jott
  • music
  • null
  • phone
  • search
  • search engine
  • tip
  • tool
  • unix
  • web development
  • yui

Blog Archive

  • ►  2008 (5)
    • ►  September (1)
    • ►  August (1)
    • ►  July (1)
    • ►  June (1)
    • ►  January (1)
  • ►  2007 (6)
    • ►  December (1)
    • ►  September (1)
    • ►  July (1)
    • ►  June (1)
    • ►  March (2)
  • ▼  2006 (10)
    • ►  November (1)
    • ▼  August (1)
      • IE Bug Using document.getElementById()
    • ►  May (2)
    • ►  April (4)
    • ►  March (2)
  • ►  2005 (10)
    • ►  August (3)
    • ►  June (2)
    • ►  February (5)
  • ►  2004 (9)
    • ►  October (2)
    • ►  September (7)
Powered by Blogger.

About Me

Unknown
View my complete profile