刹那的菜鸟

博客园 首页 新随笔 联系 管理

举例:http://localhost:5000/?sss=sdf&fdd=123

1、设置或获取整个 URL 为字符串

window.location.href  

值:  http://localhost:5000/?sss=sdf&fdd=123

2、设置或获取 URL 的协议部分

window.location.protocol

值:http:

3、设置或获取 URL 的主机部分

window.location.host

值:localhost:5000

4、设置或获取与 URL 关联的端口号码

window.location.port

值:5000

5、设置或获取与 URL 的路径部分(就是文件地址)

window.location.pathname

值:/

6、设置或获取 href 属性中跟在问号后面的部分

window.location.search

值:?sss=sdf&fdd=123

7、设置或获取 href 属性中在井号“#”后面的分段

window.location.hash

值:空

 

若有疑问可以留言。

posted on 2019-12-23 10:40  刹那的菜鸟  阅读(583)  评论(0编辑  收藏  举报