This blog is closed as of 2/2015. @EricLaw left Microsoft in 2012, but was named an IE MVP in '13 & an IE userAgent ( in '14.

URL Components in the DOM

URL Components in the DOM

  • Comments 2

The IE team has been working our way through the remaining issues reported from internal and external testing of the IE9 Release Candidate. In the course of investigating one recent internal-site compatibility bug, I ran across an interesting interoperability issue that appears to have existed since IE5 (or earlier). It isn’t well-documented, even as it is periodically rediscovered, so I figured that it was worth a mention here.

The specific issue is that Internet Explorer’s accessor methods for URL components do not match the spec in some cases. Specifically, the host property sometimes includes the port number (even when that port is the default port for the scheme) and the pathname property sometimes lacks the leading forward slash character.

You can see these quirks on a simple test page:

Screenshot of test page

When loading the page, the <A> element’s properties are incorrect, but the window.location object has the correct values. However, when the page is loaded into a dialog using the ShowModalDialog or ShowModelessDialog methods, the window.location object also has the non-standard values. Interestingly, you’ll also always see the non-standard window.location values when loading the page in Platform Preview Builds (direct hosting of MSHTML), but applications that host the Web Browser Control behave like the full browser.

This behavior only exists in Internet Explorer (and hosts of MSHTML), and it’s related to an internal boolean flag whose value is different in the affected cases.

This isn’t a regression in IE9, but it was noticed during our testing because of an unrelated change—IE9 RC throws an exception when setting the <base> element’s href to an invalid value. The site in question was using the DOM properties to construct a URL to assign to a BASE element’s href property, and that operation began throwing an exception in IE9. In IE8 and below, the invalid href was simply ignored, and as it turns out, this site wasn’t actually relying upon the BASE element at all.


Update: The problems above were fixed in IE10, but a variant (where you create the A using createElement and never add it to the body) remains unfixed in IE11: 

Page 1 of 1 (2 items)