[资料收集]js小技巧
2016-03-11 12:44 lilooo 阅读(193) 评论(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
结果: