var properties = ['href', 'origin', 'host', 'hostname', 'port', 'pathname', 'search', 'hash'];
var getLocation = function(url) {
var result = {};
var linkElem = document.createElement('a');
linkElem.href = url;
for(var i = 0, len = properties.length; i < len; i++) {
result[properties[i]] = linkElem[properties[i]];
}
return result;
};
转载于:https://www.cnblogs.com/xiaoyucoding/p/8421775.html