Skip to content

Instantly share code, notes, and snippets.

@unnamedd
Created April 25, 2012 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unnamedd/2491630 to your computer and use it in GitHub Desktop.
Save unnamedd/2491630 to your computer and use it in GitHub Desktop.
Get Parameters from QueryString
function getParameters(qs) {
qs = qs.split("+").join(" ");
var params = {}, tokens,
re = /[?&]?([^=]+)=([^&]*)/g;
while (tokens = re.exec(qs)) {
params[decodeURIComponent(tokens[1])]
= decodeURIComponent(tokens[2]);
}
return params;
/* Using:
var query = getParameters(document.location.search);
console.log(query.next)
*/
}
String.prototype.format = function(){
var pattern = /\{\d+\}/g;
var args = arguments;
return this.replace(pattern, function(capture){return args[capture.match(/\d+/)];});
};
String.prototype.contains = function(texto){
return this.indexOf(texto) != -1;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment