欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

js獲取當(dāng)前頁(yè)面的url網(wǎng)址信息

 更新時(shí)間:2014年06月12日 15:26:07   投稿:whsnow  
這篇文章主要介紹了通過(guò)js如何獲取當(dāng)前頁(yè)面的url網(wǎng)址信息,需要的朋友可以參考下
1、設(shè)置或獲取整個(gè) URL 為字符串:

window.location.href

2、設(shè)置或獲取與 URL 關(guān)聯(lián)的端口號(hào)碼:

window.location.port

3、設(shè)置或獲取 URL 的協(xié)議部分

window.location.protocol

4、設(shè)置或獲取 href 屬性中跟在問(wèn)號(hào)后面的部分

window.location.search

5、獲取變量的值(截取等號(hào)后面的部分)
復(fù)制代碼 代碼如下:

var url = window.location.search;
// alert(url.length);
// alert(url.lastIndexOf('='));
var loc = url.substring(url.lastIndexOf('=')+1, url.length);

6、設(shè)置或獲取 URL 的協(xié)議部分:

window.location.protocol

7、設(shè)置或獲取 href 屬性中在井號(hào)“#”后面的分段:

window.location.hash

8、設(shè)置或獲取 location 或 URL 的 hostname 和 port 號(hào)碼:

window.location.host

相關(guān)文章

最新評(píng)論