Check user

0

I want the user to log in to my page, javascript checks his profile on the system, and if the profile is empty, it goes to the home page.

It's simple, I'm trying this code here, but it's not working right:

<script>

  var perfil = document.querySelector('#perfil').textContent;

  if (perfil = ''){

  window.location = "../index.php";
  }
</script>

That's all I need to do, if profile is empty, then go to index, but it's not working that way there, how can I do it?

My html

    
asked by anonymous 25.05.2018 / 21:56

1 answer

0
var perfil = document.querySelector('#perfil').textContent;
   if (perfil == '') { //seu erro está aqui vc está usando atribuição e não comparação
   window.location.assign("../index.php");
}
    
25.05.2018 / 22:06