解析字符串形式的url地址
假设给定的url形字符串为:
var url = 'https://www.baidu.com:8080/aaa/1.html?id=10#name';
用a链接的形式
var aLink = window.document.createElement('a');
aLink.href = url;
console.log(aLink);
console.log(aLink.search);
console.log(aLink.hash);
...
protocol: https //协议
host: www.baidu.com:8080 //主机
hostname: www.baidu.com //主机名
port: 8080 //端口号
pathname: /aaa/1.html //路径名
search: ?id=10 //参数
hash: #name //锚点