javascript - what return 'windows.location.pathname'? -


i tested function window.locatin.pathname.

this 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! not true???  }else{    console.log('false'); //output in console      }

i think var 'location' string , contains string '/de/immobilien-auf-mallorca'.

but if include if statement (if location = /de/immobilien-auf-mallorca) don't come first part of if statement. (take above)

i don't know why maybe variable isn't string?!

maybe knows more this.

thanks help!

you have chosen particular reserved keyword log ---> location, location defaults window.location, object. solution pretty simple, replace variable name "mylocation", make trick.

var mylocation = window.location.pathname;  console.log(mylocation); // -> /de/immobilien-auf-mallorca  if(mylocation == "/de/immobilien-auf-mallorca"){   console.log('true'); //it's going work.... }else{   console.log('false'); //output in console     } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -