1.获取http协议:window.location.protocol
2.获取一个页面的主机名和端口号相当于是hostname和port:window.location.host
所以浏览器的地址是window.location.protocol+'//'+window.location.host
1.获取http协议:window.location.protocol
2.获取一个页面的主机名和端口号相当于是hostname和port:window.location.host
所以浏览器的地址是window.location.protocol+'//'+window.location.host