链接内容为 http://x.xxx.com/xxxx.xxx?x=1
window.location.href(设置或获取整个 URL 为字符串)
返回值:http://x.xxx.com/xxxx.xxx?x=1
window.location.protocol(设置或获取 URL 的协议部分)
返回值:http:
window.location.host(设置或获取 URL 的主机部分)
返回值:x.xxx.com
window.location.port(设置或获取与 URL 关联的端口号码)
返回值:空字符(如果采用默认的80端口(update:即使添加了:80),那么返回值并不是默认的80而是空字符) 或者 类似于8080的端口号
window.location.pathname(设置或获取与 URL 的路径部分(就是文件地址))
返回值:/xxxx.xxx
window.location.search(设置或获取 href 属性中跟在问号后面的部分)
返回值:?x=1
window.location.hash(设置或获取 href 属性中在井号“#”后面的分段)
版权声明:本文为KLS_CSDN原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。