'only redirect a user on login not in registration in firebase javascript

firebase.auth().onAuthStateChanged(user => {
  if(user) {
    window.location = 'home.html';
  }
});

I am trying to make a login and registration page, I have done everything but the problem is I only want to redirect user on when he clicks login in button not on register the above code is not helping it redirects even when registering. Any information you can provide me would be greatly helpful in this matter thank you



Solution 1:[1]

what about this:

document.getElementById("login-button").addEventListener("click", function(){
  window.location = 'home.html';
});

this is just a simple JS code for sending you over to other page when element with id="login-button" is clicked.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 lordsanken