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。
對當前網頁進行跳轉