How to change page with JS in html?

Viewed 120

I want when the user successfully sign up it goes to the main page. I already tried a lot of function but it doesn't work..

code :

var nama = document.getElementById("name");
var email = document.getElementById("email");
var userPw = document.getElementById("pass");

sign up code :

function store(){

var rePass = document.getElementById("re_pass");
if (userPw.value == rePass.value && nama.value != "") {
    alert("Berhasil daftar!");
} else {
    alert('Coba periksa lagi~');
    return;
}

localStorage.setItem('namaUser', nama.value);
localStorage.setItem('emailUser', email.value);
localStorage.setItem('passwordUser', userPw.value);

i tried this function also :

self.location = 'sign in.html';

}

2 Answers

Try this one. make sure to clear the space between in this segment!!! 'sign in.html'

window.location = 'sign in.html'

Try this.

window.location.replace("/");

or

window.location.href = "/";
Related