码迷,mamicode.com
首页 > Web开发 > 详细

[资料收集]js小技巧

时间:2016-03-11 13:57:33      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:

一、获取当前页面路径

from: http://www.jb51.net/article/45337.htm

设置或获取对象指定的“文件名”或路径:
window.location.pathname
结果:/bubiao/monitorCenter/map.jsp
设置或获取整个 URL 为字符串:
window.location.href
结果:http://221.77.113.233:8000/bubiao/monitorCenter/map.jsp
设置或获取与 URL 关联的端口号码:
window.location.port
结果:8000
设置或获取 URL 的协议部分:
window.location.protocol
结果:http:
设置或获取 href 属性中在井号“#”后面的分段:
window.location.hash
结果:
设置或获取 location 或 URL 的 hostname 和 port 号码:
window.location.host
结果:222.77.113.233:8000
设置或获取 href 属性中跟在问号后面的部分:
window.location.search
结果:

 

[资料收集]js小技巧

标签:

原文地址:http://www.cnblogs.com/lilooo/p/5265178.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!