In the question how to check if the url contains a given string. Javascript/jquery
the answer checks if the url contains a given string. I want to extend this to check if it contains two things name=franky && gender=male. I tried
if(window.location.href.indexOf("name=franky" && "gender=male") > -1)
which appeared to work initially, but with further testing I have found it seems to work if only one of name or gender is present. Where am I going wrong here?
You could break it into two parts and call indexOf twice instead of trying to check for both strings in the same call. Something like this: