You can try to use indexOf()
in string to find the string you are checking for.
$(document).ready(function() {
if (location.search.indexOf('name=john') !== -1)
alert("my name is john");
});
This way is very basic, does not cover all the possibilities.
If you really want to get the URL variable, then use
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
and check by getParameterByName('name') == 'john'
.