Skip to content

Instantly share code, notes, and snippets.

@g8up
Created December 9, 2015 07:12
Show Gist options
  • Save g8up/fe71b86a1bd7ce11b8e1 to your computer and use it in GitHub Desktop.
Save g8up/fe71b86a1bd7ce11b8e1 to your computer and use it in GitHub Desktop.
获取地址栏携带的参数
function parseParam( search ){
var params = {};
if( search.length > 2 ){
if( search[0] === '?' ){
var _search = search.slice(1);
var keyVals = _search.split('&');
keyVals.forEach(function(pair){
var kv = pair.split('=');
if( kv.length === 2 ){
params[kv[0]] = kv[1];
}
});
}
}
return params;
}
function getParams(){
var search = window.location.search;
console.log( parseParam( search ) );
}
//# sourceURL=sigma.js
getParams()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment