How To Access Request Query String Parameters In Javascript?
I've seen numerous solutions that utilize RegEx, and to be quite frank, that seems ridiculously excessive since javascript is so versatile. There must be a simpler way to access re
Solution 1:
I found a useful method in the depths of the net.
functionquerySt(Key) {
var url = window.location.href;
KeysValues = url.split(/[\?&]+/);
for (i = 0; i < KeysValues.length; i++) {
KeyValue = KeysValues[i].split("=");
if (KeyValue[0] == Key) {
returnKeyValue[1];
}
}
}
Downvotes and plugins aside, thanks anyways.
Solution 2:
You can use jQuery plugin Purl (A JavaScript URL parser) v2.3.1
var queryStringParameter = $.url().param('queryStringParameter');
Solution 3:
jQuery BBQ plugin to the rescue. See deparam method
Post a Comment for "How To Access Request Query String Parameters In Javascript?"