Last active
August 29, 2015 14:21
-
-
Save wdmtech/91f908121f6d4082212e to your computer and use it in GitHub Desktop.
Gets query string parameters in jQuery
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
// Gets query string parameters | |
$.urlParam = function(name){ | |
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); | |
if(results && results.length > 0) { | |
return results[1] || 0; | |
} | |
}; | |
// Example usage | |
if($.urlParam('screen_grab')) | |
{ | |
// trigger click on .thing | |
$('.thing').trigger('click'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment