Created
April 23, 2017 17:26
-
-
Save LeonardoCiaccio/7eb65e6b0285264be35302825fd8a220 to your computer and use it in GitHub Desktop.
From http://stackoverflow.com/questions/6539761/window-location-search-query-as-json/40061376#40061376
This file contains 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
var params = "?q=Hello World&c=Awesome"; | |
params = "{\"" + | |
params | |
.replace( /\?/gi, "" ) | |
.replace( /\&/gi, "\",\"" ) | |
.replace( /\=/gi, "\":\"" ) + | |
"\"}"; | |
params = JSON.parse( params ); | |
alert( decodeURIComponent( params.q ) ); | |
alert( decodeURIComponent( params.c ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment