窗口位置不起作用,我已经尝试过了

Window.location not working I have tried eveything

本文关键字:过了 位置 不起作用 窗口      更新时间:2023-09-26
/*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?";
    }
}

窗口位置不起作用。页面名称是正确的,当信息正确时,程序会给出 window.alert,但它会加载到新页面。有人知道为什么它不起作用吗?请帮忙!我已经在这里待了几个小时了。

您从本地文件系统打开了 html。尽管乍一看似乎可以工作,但出于安全原因,许多功能都被禁用了。其中之一可能是页面重定向。

我建议您获取一些开发网络服务器,并通过它提供文件。请参阅 Express或connect for nodejs,或以下内容 for python:

  • 导航到 Web 应用的根目录
  • 为 python3 运行 python -m http.server,或为 python2 运行 python -m SimpleHTTPServer
  • 在浏览器中打开http://localhost:8000

大多数JavaScript和HTML IDE-s也有一些内置的服务功能。