Created
November 30, 2017 09:27
-
-
Save cat-kun/f6ee2c5f36d2ada0bf3198edaa73fe6a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
若地址栏URL为:abc.html?m=tomms&c=allsearchlist&pageNo=1&pageNum=20&text=1 | |
```js | |
//JavaScript获取url,并把url中的参数变成数组的方法,arr数组的值就是各参数值 | |
var url = window.document.location.href.toString(); | |
var u = url.split("?"); | |
var arr = []; | |
if(typeof(u[1]) == "string"){ | |
u = u[1].split("&"); | |
for(var i in u){ | |
var a = (u[i].split("=")); | |
arr[a[0]] = decodeURI(a[1]); | |
} | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment