0

Alerts are working in both conditions but I can't make a transfer to my HTML link if the password is correct I ALSO TRIED - document.location.href / window.location.href / document.location.replace

document.querySelector('#submit').onclick = function () {

    var pass = document.querySelector('#pass').value;
    var passrepeat = document.querySelector('#passrepeat').value;
    if (pass === passrepeat) {
        //alert("GJ")
        local.href = "SuccessfulLogin.html" 
    }
    else {
        alert("Wrong pass")
    }
}

2 Answers2

1

The correct is window.location.href

and also use event.preventDefault() in submit function.

document.querySelector('#submit').onclick = function (event) {
  event.preventDefault()
 ...
}
BeHappy
  • 3,705
  • 5
  • 18
  • 59
0
window.location.replace("SuccessfulLogin.html");
window.open("SuccessfulLogin.html", "_self");
window.open("SuccessfulLogin.html")

Would usually open in a new tab but the "_self" parameter makes it open in the same tab.

Justin Liu
  • 581
  • 6
  • 21