chaplinjs / chaplin

HTML5 application architecture using Backbone.js
http://chaplinjs.org
Other
2.85k stars 231 forks source link

Internet Explorer reload on link with relative URL #878

Closed chrstph-dvx closed 8 years ago

chrstph-dvx commented 8 years ago

Links are considered external in IE(9 to 11) and then trigger a reload. location.protocol and location.hostname are empty in case of a relative URL.

This function seems to fix it. (Layout.prototype.isExternalLink)

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.host == "") {
      location.href = location.href;
    }
    return location;
};

source: http://stackoverflow.com/questions/736513/how-do-i-parse-a-url-into-hostname-and-path-in-javascript

shvaikalesh commented 8 years ago

@sayam91, thanks for the report, confirmed in IE10. #879 should fix this.