Skip to content

Instantly share code, notes, and snippets.

@thomasJang
Last active August 29, 2015 14:23
Show Gist options
  • Save thomasJang/ae46c01efb2ae13e402c to your computer and use it in GitHub Desktop.
Save thomasJang/ae46c01efb2ae13e402c to your computer and use it in GitHub Desktop.
window.location parameter convert to JSON
// window.location parameter convert to JSON
var
param = {},
parameter = window.location.search.replace(/^\?/, '').split(/&/g),
i = parameter.length, pidx;
while(i--){
param[ parameter[i].substr(0, pidx = parameter[i].indexOf("=")) ] =
parameter[i].substr( pidx + 1 );
}
console.log(param);
@thomasJang
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment