且构网

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

防止使用后退按钮(在IE中)

更新时间:2023-12-03 08:05:34

不要这样做,只是不要这样做。这是糟糕的界面设计,并迫使用户的浏览器以他们不期望的方式运行。

Don't do this, just don't. It's bad interface design and forces the user's browser to behave in a way that they don't expect.

我认为任何成功停止我的后退按钮的脚本都可以工作是一个黑客,我希望IE团队为它发布一个安全修复程序。

I would regard any script that successfully stopped my back button from working to be a hack, and I would expect the IE team to release a security-fix for it.

后退按钮是他们的程序界面的一部分,而不是你的网站。

The back button is part of their program interface, not your website.

在您的具体情况下,我认为***的办法是向页面添加一个卸载事件,如果用户尚未填写表单,则会向用户发出警告。后退按钮不受影响,用户将收到警告他们的行动。

In your specific case I think the best bet is to add an unload event to the page that warns the user if they haven't completed the form. The back button would be unaffected and the user would be warned of their action.