完整的URL由这几个部分构成:scheme://host:port/path?query#fragment ,各部分的取法如下:
window.location.href:获取完整url的方法:,即scheme://host:port/path?query#fragment
window.location.protocol:获取rul协议scheme
window.location.host:获取host
window.location.port:获取端口号
window.location.pathname:获取url路径
window.location.search:获取参数query部分,注意此处返回的是?query
window.location.hash:获取锚点,#fragment