Thursday, May 25th, 2006
Glen Jones has discovered a little “gotcha” while he was wokring on one of his scripts – an issue with the retrevial of the href attribute when working with the DOM.
The href attribute is different to other element attributes in that the value set can be relative to the context of the page URL. The browser will look at the pages current URL and derive an absolute URL for the link. This is the root of the problem, some browsers return the text of the attribute and others return the derived absolute URL. The results also differ by the method you use to retrieve the href attribute.
He gives the results of a few tests he performed (with IE and Gecko) to see underwhat circumstances it would return the correct attribute text and when it would make it relative. He had made some comments about which way was the “more correct” way, but has since changed them (because of some comments) and noted that the way IE tends to handle it is incorrect.
Posted by Chris Cornutt at 6:30 am