var myurl = window.location;
    var pos = myurl.IndexOf("memberId");
    if (pos = -1) {
        alert("false");
    } else {
        alert("true");
     }
For some reason I can't seem to get this simple method to work. Chrome says 'myurl does not contain the method 'indexOf''. Any reason?
Maybe typo but it should be
myurl.indexOf
lowercase i.
And location is an object, so you want:
var myurl = window.location.href;
(and all the other things people say in the comments and other answers ;))
Update: To see what kind of properties an object has, just type, in this case, window.location in the console:

window.location returns an object. Perhaps you wanted window.location.pathname? :-)
There's also a problem with this line:
if (pos = -1)
It should be
if (pos == -1)
                        try var myurl = window.location.pathname;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With