我想要一根绳子
var a = "http://example.com/aa/bb/"
把它加工成一个物体
a.hostname == "example.com"
和
a.pathname == "/aa/bb"
我想要一根绳子
var a = "http://example.com/aa/bb/"
把它加工成一个物体
a.hostname == "example.com"
和
a.pathname == "/aa/bb"
var getLocation = function(href) {
var l = document.createElement("a");
l.href = href;
return l;
};
var l = getLocation("http://example.com/path");
console.debug(l.hostname)
>> "example.com"
console.debug(l.pathname)
>> "/path"