Is it possible using jquery (or just javascript) to check for the existence of a query string on the URL?
+6
A:
Yes, the location object has a property search that contains the query string.
alert(window.location.search);
Felix Kling
2010-07-12 21:02:01
A:
document.location contains information about the URL, and document.location.search contains the query string, e.g. ?foo=bar&spam=eggs. As for testing its presence, how about:
if(document.location.search.length) {
// query string exists
} else {
// no query string exists
}
No jQuery required :o
Matchu
2010-07-12 21:02:45
A:
I would think you could use the javascript match operator.
var url = window.location.search;
if (url.match("your string").length > 0) {
}
Neil
2010-07-12 21:03:05
A:
Check out http://rixi.us/post/791257125/get-and-server-free-dynamic-contet
a method to extract any query string parameters
Use::
if (_GET['key']) {
var key = _GET['key']
}
Rixius
2010-07-12 21:05:07