The .indexOf() function only looks for a single string. To test for two strings you need two calls to .indexOf() as per Christofer's answer:
if(window.location.href.indexOf("name=franky") > -1 &&
window.location.href.indexOf("gender=male") > -1)
The reason I'm posting an answer too is to briefly explain how the && operator works: given expr1 && expr2, the && operator "Returns expr1 if it can be converted to false; otherwise, returns expr2."
What does "converted to false" mean? Basically null, undefined, 0, NaN and "" (empty string) are "falsy" and will be "converted to false". non-zero numbers, non-empty strings and any object are "truthy" and will be converted to true.
That means when you said "name=franky" && "gender=male" the && operator tests the first operand, finds that (in this case) it can't be converted to false, so it returns "gender=male". So the reason your code seemed to work some of the time is that in effect it was doing this:
if(window.location.href.indexOf("gender=male") > -1)