gpt4 book ai didi

Javascript 页面重新路由

转载 作者:行者123 更新时间:2023-11-28 00:16:29 25 4
gpt4 key购买 nike

我们正在使用 JavaScript 制作一个聊天 Web 应用程序,我们将用户 session 存储在 cookie 中。我们的一个页面要求用户输入他或她的用户名,然后按“Go”重定向到聊天室。通过按钮调用存储值功能。它依次调用 SetCookie 函数,该函数调用重定向。但是我们的按钮不会将它们重定向到下一页。

function setCookie(name, value){
document.cookie=name + "=" + escape(value) + ", path=/; expires=" + expiry.toGMTString();
console.log(document.cookie+"hello");
var url = "file:///C:/Users/Admin/Documents/Mathworks/Lobby.html";
window.location.replace("file:///C:/Users/Admin/Documents/Mathworks/Lobby.html");
}
console.log(document.cookie);
//this should set the UserName cookie to the proper value;
function storeValues(form)
{
setCookie("userName", document.getElementById("inputBox").value);
console.log(document.cookie+"word");
return true;
}

最佳答案

它是document.location.replace(),而不是window.location.replace()。您也可以尝试 document.location.assign(url)

关于Javascript 页面重新路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30424275/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com