Skip to content

Instantly share code, notes, and snippets.

@nikolasleblanc
Created February 24, 2014 15:14
Show Gist options
  • Save nikolasleblanc/9190149 to your computer and use it in GitHub Desktop.
Save nikolasleblanc/9190149 to your computer and use it in GitHub Desktop.
Access querystring from javascript
$.urlParam = function(name, url){
if(!url){
url = window.location.href;
}
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(url);
if (!results)
{
return 0;
}
return results[1] || 0;
}
//$.urlParam('varName');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment