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



Read More
Posted in browser specific, coding, example, web development | No comments
Newer Posts Older Posts Home
Subscribe to: Comments (Atom)

Popular Posts

  • Capturing the close event.
    When programming a thin-client application using HTML and JavaScript and you want to capture the closing event, it is not as easy as one thi...
  • Musicovery
    I found this site courtesy of http://www.i-am-bored.com . The name of the site is Musicovery . This is a site where you can listen to musi...

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