js 獲取url引數

2022-09-05 18:15:13 字數 492 閱讀 2352

//設定或獲取物件指定的檔名或路徑。

alert(window.location.pathname);

//設定或獲取整個 url 為字串。

alert(window.location.href);

//設定或獲取與 url 關聯的埠號碼。

alert(window.location.port);

//設定或獲取 url 的協議部分。

alert(window.location.protocol);

//設定或獲取 href 屬性中在井號「#」後面的分段。

alert(window.location.hash);

//設定或獲取 location 或 url 的 hostname 和 port 號碼。

alert(window.location.host);

//設定或獲取 href 屬性中跟在問號後面的部分。

alert(window.location.search);

js獲取url引數

string.substring from,to 返回字串的乙個子串。包括from的字元,不包括to的字元,長度為to from,省略to,則返回的子串到字串的結尾。string.indexof search,from 在from處開始檢索字串中是否存在search值,如果存在,返回第一次出現的位置...

js 獲取url引數

因為寫的乙個回放遊戲的模組要發布成web版本,而我的程式裡需要獲取幾個資料以訪問服務端的網頁,要獲取的資料是通過客戶端傳過來的,發布後的web版本是他們後端拿去用的,所以我需要獲取自己的url引數,剛開始我並不知道這是什麼,查了資料後才發現,就是獲取位址列而已,如果早知道,也不會浪費那麼多時間了。很...

JS 獲取URL引數

獲取url引數 單個引數的js方法 多個引數的js方法 然後我們通過呼叫此函式獲取對應引數值 以此獲取url串中所帶的同名引數 二 正則分析法。function getquerystring name var reg new regexp name i var r window.location.s...