Created
June 22, 2016 21:45
-
-
Save leepettijohn/3f50b8c78456fb0da9fc8836e8ca9e9a to your computer and use it in GitHub Desktop.
jQuery - Get GET variables
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
| var $_GET = {}; | |
| document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () { | |
| function decode(s) { | |
| return decodeURIComponent(s.split("+").join(" ")); | |
| } | |
| $_GET[decode(arguments[1])] = decode(arguments[2]); | |
| }); | |
| //This will either alert the "id" variable in the URL or return 'undefined' | |
| alert($_GET['id']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment