mercredi 30 septembre 2015

what return 'windows.location.pathname'? It isn't a string?

I tested something with the function window.locatin.pathname.

This is my js script:

   var location = window.location.pathname;

   console.log(location); // -> /de/immobilien-auf-mallorca

    if(location == "/de/immobilien-auf-mallorca"){
      console.log('true'); //doesn't work! It is not true???
    }else{
      console.log('false'); //Output in my console    
    }

I think that my var 'location' is a string and contains this string '/de/immobilien-auf-mallorca'.

But if I include an if statement (if location = /de/immobilien-auf-mallorca) I don't come into the first part of my if statement. (Take a look above)

I don't know why maybe my variable isn't a string?!

Maybe someone knows more about this.

Thanks for help!

Aucun commentaire:

Enregistrer un commentaire