測試url :
.com:80/aaa/a.aspx?id=5&name=yh
function getquerystring(name)
var reg = new regexp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location
.search
.substr(1).match(reg);
if (r != null)
return "";}
//該函式傳入引數名則返回對應的值,傳入「url」則返回檔案路徑
var url = getquerystring("url"); ///aaa/a.aspx
var type1 = getquerystring("name"); //yh
1、window.location
.href(設定或獲取整個 url 為字串)
2、window.location
.protocol(設定或獲取 url 的協議部分)
3、window.location
.host(設定或獲取 url 的主機部分)
4、window.location
.port(設定或獲取與 url 關聯的埠號碼)
5、window.location
.pathname(設定或獲取與 url 的路徑部分(就是檔案路徑及頁面位址))
6、window.location
.search(設定或獲取 href 屬性中跟在問號後面的部分)
7、window.location
.hash(設定或獲取 href 屬性中在井號「#」後面的分段)
獲取當前頁面的URL資訊
以前在做 的時候,經常會遇到當前頁的分類高亮顯示,以便讓使用者了解當前處於哪個頁面。之前一直是在每個不同頁面寫方法。工程量大,也不便於修改。一直在想有什麼簡便的方法實現。後來在網上查到可以用獲取當前url的詳細資訊來判斷。所以收集了jquery獲取url的函式的資料。設定或獲取物件指定的檔名或路徑。...
C 獲取當前頁面的url
2 通過js獲取 thisdloc document.location thisurl document.url thishref document.location.href thissloc self.location.href thistloc top.location.href thispl...
JQUERY獲取當前頁面的URL資訊
以前在做 的時候,經常會遇到當前頁的分類高亮顯示,以便讓使用者了解當前處於哪個頁面。之前一直是在每個不同頁面寫方法。工程量大,也不便於修改。一直在想有什麼簡便的方法實現。後來在網上查到可以用獲取當前url的詳細資訊來判斷。所以收集了jquery獲取url的函式的資料。設定或獲取物件指定的檔名或路徑。...