Created
June 21, 2012 16:53
-
-
Save m4dz/2966977 to your computer and use it in GitHub Desktop.
Construct an object with the GET passing values
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 getParams() { | |
var href, | |
paramList, | |
arg, | |
refs = {}; | |
href = document.defaultView.location.href; | |
if ( -1 != href.indexOf("?") ) | |
{ | |
paramList = href.split("?")[1].split(/&|;/); | |
for ( p in paramList ) | |
{ | |
arg = paramList[ p ].split("="); | |
refs[ arg[0] ] = arg[1]; | |
} | |
} | |
return refs; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
protip : You can pass default values by filling the
refs
object