Monday, May 20, 2024
98
rated 0 times [  103] [ 5]  / answers: 1 / hits: 20672  / 11 Years ago, fri, august 2, 2013, 12:00:00

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 request parameters.



Could somebody demonstrate for me?


More From » query-string

 Answers
28

I found a useful method in the depths of the net.



function querySt(Key) {
var url = window.location.href;
KeysValues = url.split(/[?&]+/);
for (i = 0; i < KeysValues.length; i++) {
KeyValue = KeysValues[i].split(=);
if (KeyValue[0] == Key) {
return KeyValue[1];
}
}
}


Downvotes and plugins aside, thanks anyways.


[#76554] Friday, August 2, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dominiqued

Total Points: 189
Total Questions: 122
Total Answers: 103

Location: Ghana
Member since Sun, Mar 27, 2022
2 Years ago
;