Choose a location:
posted 4/10/2012 by Raghav Khunger
Following is the JavaScript code to check whether a key is present in querystring or not:
<script type="text/javascript"> var queryKeyPresent = function(key) { var url = window.location.href; if (url.indexOf('?' + key + '=') != -1) { return true; } else if (url.indexOf('&' + key + '=') != -1) { return true; } return false; }; </script>
Usage:
var check = queryKeyPresent('q'); var check2 = queryKeyPresent('userid');
The above code will look whether the key exists just after the questionmark (?) or present in some successive keys in querystring.
What kind of email newsletter would you prefer to receive from CodeAsp.Net? 18