防止使用后退按钮(在IE中) [英] Prevent Use of the Back Button (in IE)

查看:118
本文介绍了防止使用后退按钮(在IE中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我目前工作地点的中小企业想要尝试禁用某些页面的后退按钮。我们有一个页面,用户进行一些选择并提交它们进行处理。在某些情况下,他们必须在另一页上输入评论。

So the SMEs at my current place of employment want to try and disable the back button for certain pages. We have a page where the user makes some selections and submits them to be processed. In some instances they have to enter a comment on another page.

用户已经想到的是,如果他们提交信息并转到带有评论的页面然后点击后面,他们就不必输入评论按钮返回上一页。

What the users have figured out is that they don't have to enter a comment if they submit the information and go to the page with the comment and then hit the back button to return to the previous page.

我知道有几种不同的解决方案(其中许多解决方案比禁用后退按钮更优雅),但这就是我留下的。是否可以通过改变后退按钮的行为来阻止某人返回上一页。 (如提交 - >返回错误的排序)。

I know there are several different solutions to this (and many of them are far more elegant then disabling the back button), but this is what I'm left with. Is it possible to prevent someone from going back to the previous page through altering the behavior of the back button. (like a submit -> return false sorta thing).

由于双重发布信息,我不能让它返回上一页然后转到当前页面。我只能直接离开当前页面。我用谷歌搜索它,但我只看到帖子说它将永远返回上一页。我希望有人有一些疯狂的功夫技能可以使这成为可能。

Due to double posting information I can't have it return to the previous page and then move to the current one. I can only have it not direct away from the current page. I Googled it, but I only saw posts saying that it will always return to the previous page. I was hoping that someone has some mad kung foo js skills that can make this possible.

我知道每个人都说这是个坏主意,我同意,但有时候你必须做你所说的。

I understand that everyone says this is a bad idea, and I agree, but sometimes you just have to do what you're told.

推荐答案

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

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.

这篇关于防止使用后退按钮(在IE中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆