Created
February 24, 2014 15:14
-
-
Save nikolasleblanc/9190149 to your computer and use it in GitHub Desktop.
Access querystring from 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
$.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