![](/img/trans.png)
[英]Passing value input by user to another html page using javascript and redirect using javascript function
[英]Is it possible to redirect a user to another page without clearing their history of the page using JavaScript & HTML?
我正在尝试将用户重定向到验证页面,单击按钮后,我希望他们回到被重定向之前的位置。
我遇到的问题是他们所在的页面没有存储在他们的浏览器历史记录中。
我试过使用window.location.assign
和window.location.href
。
我使用 Edge 作为浏览器进行测试。
原始页面:
if(x === -1) {
window.location.assign = "Redirect to Page";
}
重定向到页面:
function yes() {
// attached to a button
history.go(-1);
}
我希望回到原始页面,因为我的许多页面都会将用户发送到“重定向到页面”
我真的很感激这里的任何帮助,我对编程很陌生,老实说几乎不知道 php 和 jQuery 之间的区别。
如果我忽略了包含重要信息,请原谅。
非常感谢你的帮助!
我最终使用 localStorage.setItem 和 localStorage.getItem 来跨页面存储 URL 的值。
非常感谢您的解决方案,我必须了解有关 php 和 JQuery 的更多信息
连接/断开用户连接似乎是一个问题。 如果我是对的,那么您可能不应该针对上一页,而是针对特定页面?
我遇到了同样的问题,我做了一个小项目示例: https : //github.com/nicoesiea/authentification你可以看看并做同样的...我想它应该可以帮助你解决你的问题。 (现在可能是个老项目了……而且安全性非常差——看看数据库里的密码,它们甚至没有加密……)
但是主体在这里,您会显示登录模式弹出窗口(或重定向到页面)以查询登录名/密码,以便在用户有效与否时检查数据库。 这是你想要做的吗?
祝你有美好的一天,问候,尼科
传递表示要返回的页面的查询参数:
window.location = `redirect.html?redirect=${encodeURIComponent(window.location)}`;
在redirect.html
:
function yes() {
window.location = decodeURIComponent(new URL(window.location).search.split("redirect")[1].split("=")[1]);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.