Skip to content

Instantly share code, notes, and snippets.

@cat-kun
Created November 30, 2017 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cat-kun/f6ee2c5f36d2ada0bf3198edaa73fe6a to your computer and use it in GitHub Desktop.
Save cat-kun/f6ee2c5f36d2ada0bf3198edaa73fe6a to your computer and use it in GitHub Desktop.
若地址栏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