Reputation: 161
/*jslint plusplus: true*/
function signin() {
'use strict';
localStorage.setItem("index", 0);
var get, sn, get1, text, i;
get = localStorage.getItem("login");
get1 = JSON.parse(get);
sn = document.getElementById("studentnumber").value;
if (sn === get1[0].student) {
window.alert("Welcome, " + get1[0].fName + get1[0].lName);
window.location = 'Newsfeed.html';
} else {
window.alert = "Sorry Student Number or Password is incorrect! Did up already make an account?";
}
}
The window.location is not working. The page name is right and the program gives the window.alert when the information is correct but it would load to the new page. Anyone know why it doesn't work? Please help! I've been at it for hours.
Upvotes: 3
Views: 134
Reputation: 29926
You opened your html from the local filesystem. Although it seems to work at first glance, many features are disabled for security reasons. One of them might be page redirect.
I suggest you to grab some development webserver, and serve your files through that. See express or connect for nodejs, or the following for python:
python -m http.server
for python3, or python -m SimpleHTTPServer
for python2http://localhost:8000
in your browserMost JavaScript and HTML IDE-s have some builtin serving functionality too.
Upvotes: 5