使用JS,獲取URL中指定參數的值

 1 /**
 2  * 獲取URL中指定參數的值
 3  * 
 4  * @param name 參數名稱
 5  * @returns
 6  */
 7 function getQueryString(name) {
 8     var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
 9     var r = window.location.search.substr(1).match(reg);
10     if (r != null) {
11         return unescape(r[2]);
12     }
13     return null;
14 }
相關文章
相關標籤/搜索