Eby
Eby

Reputation: 93

How to change page with JS in html?

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';

}

Upvotes: 2

Views: 672

Answers (2)

David Gomez
David Gomez

Reputation: 114

Try this.

window.location.replace("/");

or

window.location.href = "/";

Upvotes: 0

Nisansali Nikapotha
Nisansali Nikapotha

Reputation: 851

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

window.location = 'sign in.html'

Upvotes: 1

Related Questions