設置或獲取整個 URL 為字符串:
window.location.href
獲取內容:http://10.100.0.8:7000/SVP/
"window.location.href" "http://10.30.60.187:7000/PPIS/templates/WfrmMain_Test.html"
備注:設置頁面跳轉,可更改此值
設置或獲取與 URL 關聯的端口號碼:
window.location.port:7000
設置或獲取 URL 的協議部分
window.location.protocol
設置或獲取 href 屬性中跟在問號后面的部分
window.location.search
獲取變量的值(截取等號后面的部分)
復制代碼 代碼如下:
var url = window.location.search;
// alert(url.length);
// alert(url.lastIndexOf('='));
var loc = url.substring(url.lastIndexOf('=')+1, url.length);
設置或獲取 href 屬性中在井號“#”后面的分段:
window.location.hash
設置或獲取 location 或 URL 的 hostname 和 port 號碼:
window.location.host
獲取內容:10.100.0.8:7000
window.location.hostname
獲取內容:10.100.0.8
獲取當前用戶訪問的ip地址以及城市地區
前提:需要聯網
引用下面的js:
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
直接獲取IP和城市名:
alert(returnCitySN['cip'] + returnCitySN['cname']);
其他
"document.domain" "10.30.60.187"
個人隨筆,如有錯誤,敬請指正