I have a login page and a content page. Pressing the login button will open the content page in a new tab but I want it to open in the same tab. Tried window.location.href but it doesn't work for some reason.
function validate() {
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
if (username == "marin" && password == "12345678") {
window.open("file:///C:/Users/lukam/OneDrive/Radna%20povr%C5%A1ina/stranica/stranica1_1.html")
return false;
} else {
alert("login je pogresan")
}
}
<div>
<label for="Username">Username</label>
<input type="text" name="Username" id="username">
</div>
<div>
<label for="password">Password</label>
<input type="password" name="password" id="password">
</div>
<button type="submit" class="btn-submit" onclick="validate()">Login</button>