Created
December 22, 2012 08:51
-
-
Save takumakei/4358101 to your computer and use it in GitHub Desktop.
parse query string in javascript
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
function queryString(name) { | |
var results = new RegExp( | |
'[\\?&]' + | |
name.replace(/[\[]/, '\\\[').replace(/[\]]/, '\\\]') + | |
'=([^&#]*)' | |
).exec(window.location.search); | |
if (null === results) return ''; | |
return decodeURIComponent(results[1].replace(/\+/g, ' ')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment