The Difference Between href
and getAttribute(’href’) in JavaScript
For the HTML code <a id="aboutLink" href="/about/">about</a>, the document.getElementBy Id('aboutLink').href will return the full URL of the linked resource, for example http://somesite.com/about/.
If you want to get the exact value of the href attribute, you’d use document.getElementById('aboutLink').getAttribute('href'), which returns /about/. Yea, right – not in IE and Opera (both Win and Mac). See demo.

2 Comments
I’ve been frustrated with IE’s lack for supporting that very handy method of retrieving element attributes for a long time, frustrating.
Comment (#) by Justin P — 29th August 2005.
Check out the solution posted here:
link to quirksmode.org. This saved my life.
Comment (#) by endryou — 5th September 2005.
Sorry, the comment form is closed at this time, but if you have anything to say, please send me a message.