dimanche 16 mai 2021

Javascript - comparing loaction.pathname not working as expected with or operator

I am trying to get the loacation.pathname of the current page and compare it to see if its /Login or /Register, if it is one of those the code in the if should not be executed.

Code:

if (location.pathname != '/Login' || location.pathname != '/Register')
     {
       prevView.push(location.href); // Add View to PreviousView so when needed we can navigate back to previous Page/View
       prevView.shift(); // Remove the First element from the array
     }

I also tried:

if ((location.pathname != '/Login') || (location.pathname != '/Register')

and

 if (((location.pathname != '/Login') || (location.pathname != '/Register')))

But not working - what am I doing wrong.

img1

Img2

Aucun commentaire:

Enregistrer un commentaire