Re: The getAttribute() method

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Christoph Boget wrote:

document.getElementById( 'MyFormId' ).getAttribute( 'action' )

? In Firefox, you get what you would expect; you get "/post/to/page.html". However, IE decides to go it's own way and returns the input object with the name "action". Huh? Why is it seeing the input element as an attribute? And not it's actual 'action' attribute?

getAttribute in IE's HTML DOM is broken, it does not access the attribute value of the element object, instead it returns the property of that element object.
They are trying to fix that in IE 8, IE 8 beta 1 is now available and IS supposed to fix the getAttribute behaviour but I have found cases (e.g. element.getAttribute('onclick')) where getAttribute is still broken in the beta release.
See <URL:http://www.microsoft.com/windows/products/winfamily/ie/ie8/readiness/DevelopersNew.htm#dom>


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
.