我想带一个弦
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"