Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
handle url parsing in IE
// the web is crazy
function getLocation(href) {
var location = document.createElement("a");
location.href = href;
// IE doesn't populate all link properties when setting .href with a relative URL,
// however .href will return an absolute URL which then can be used on itself
// to populate these additional fields.
if ( == "") {
location.href = location.href;
return location;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.