且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在登录后禁用浏览器后退按钮

更新时间:2023-12-03 08:14:28

不要......

浏览器是最终用户的私有财产。你所拥有的只是浏览器的内部框 - 称为窗口...

设计你的应用程序,使浏览器的后退和前进按钮不会产生问题......

您可以登录您已经登录的登录页面(某种状态)并重定向到推荐人页面...

再次不要乱用浏览器,你是在那里的客人,如果你表现得不好,你将被扔掉......
Do not...
The browser is the private property of the end-user. All you have is the inside box of the browser - called window...
Design your application in such way that back and forward buttons of the browser will not create a problem...
You maybe can check in your login page that you already logged in (some kind of state) and redirect to the referrer page...
Again do not mess with the browser, you are a guest there and you will be thrown away if you behave not nice...


我建​​议在登录时检查 Session Page。



如果会话存在,则重定向到 Home 或某些登陆页面根据您网站的逻辑。
I would suggest to check for Session on Login Page.

If Session exists, then redirect to Home or some Landing page according to your website's logic.


在页面上,您的页面在登录后重定向,将此javascript代码简单地放在设计页面上,我使用此代码和它总是为我工作。





function disableBackButton(){

window.history.forward();

}




谢谢
on the page , where your page redirected after login, put this javascript code simple on design page, I use this code and it always work for me.


function disableBackButton() {
window.history.forward();
}


Thanks