1. window.location.href
(设置或获取整个 URL 为字符串)
如:http://localhost:8080/box-web/web/html/luaedit.html?device_id=217&strategy_id=730
2,window.location.protocol
URL 的协议部分
返回值:http:
3,window.location.host
URL 的主机部分,
返回值:localhost:8080 (如果是域名则不会返回端口号)
4,window.location.port
URL 的端口部分。如果采用默认的80端口(update:即使添加了:80),那么返回值并不是默认的80而是空字符。
本例返回值:8080
5,window.location.pathname
URL 的路径部分(就是文件地址)
返回值:/box-web/web/html/luaedit.html
6,window.location.search
查询(参数)部分。除了给动态语言赋值以外,我们同样可以给静态页面,并使用javascript来获得相信应的参数值
返回值:?device_id=217&strategy_id=730
7,window.location.hash
锚点
返回值:空 (如果url中strategy_id=730后面还有值为strategy_id=730#test,则输出#test)
在js中还在类是的方法document.location、document.URL window.location.href 当前页面完整 URL。
对当前网页进行跳转