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
(function (window) { | |
//declare the variables here, | |
//as js variable hoisting will do this | |
//here anyway | |
var m, queryString, re; | |
//if the window query object does not exist | |
if (!window.query) { | |
//create it | |
window.query = {}; | |
//get the query string (without the #) | |
queryString = location.search.substring(1); | |
//declare the regex | |
re = /([^&=]+)=([^&]*)/g | |
//execute the regex for each query parameter | |
while (m = re.exec(queryString)) { | |
//add the query parameter to the query object | |
window.query[decodeURIComponent(m[1])] = decodeURIComponent(m[2]); | |
} | |
} | |
}(window)); |
No comments:
Post a Comment