我们可以通过javascript禁用浏览器的按钮(后退/前进/刷新)吗 [英] Can we disable browser's buttons(back/forward/refresh) by javascript

查看:37
本文介绍了我们可以通过javascript禁用浏览器的按钮(后退/前进/刷新)吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
禁用浏览器的后退按钮

有没有办法通过javascript禁用浏览器(特别是IE)后退按钮、前进按钮、刷新按钮.因此,当任何用户单击任何按钮时都不会发生任何事情.

Is there any way to disable browser(specifically IE) BACK button, FORWARD button, REFRESH button by javascript. So that, when ever any user will click on any button nothing will happen.

推荐答案

不,你不能可靠地、合理地做到这一点.甚至 IE 的信息亭模式"也允许后退、前进和刷新(通过键盘快捷键).

No, you cannot reliably, reasonably do that. Even IE's "kiosk mode" allows back, forward, and refresh (via keyboard shortcuts).

在实际网页(网络上的真实页面)上,禁用后退/前进/刷新当然是极其不适当的行为,我认为这不是您想要做的.(相反,使用历史库等来确保您的页面/网络应用程序实际使用后退和前进按钮来执行用户期望的操作.)

On an actual web page (a real page out on the web), disabling back/forward/refresh would of course be extremely inappropriate behavior and I assume that's not what you're trying to do. (Instead, use history libraries and such to ensure your page/web app actually works with the back and forward buttons to do what the user expects.)

请注意,如果您提供一个打开新窗口的链接(在大多数现代浏览器中实际上可能最终成为一个新选项卡),您的页面将是该窗口历史记录中的第一页,因此返回按钮将自动被禁用.如果您的页面没有在其他任何地方提供任何链接,它将保持这种状态.如果用户没有返回,根据定义,他们不能前进.但是,您对刷新无能为力.

Mind you, if you provide a link that opens a new window (which will probably actually end up being a new tab in most modern browsers), your page will be the first page in that window's history and so the Back button will automatically be disabled. And if your page doesn't offer any links anywhere else, it'll stay that way. And if the user hasn't gone Back, by definition they can't go Forward. Nothing you can do about Refresh, though.

如果您有真正禁用这些操作的真正原因(某种 Intranet 应用程序,诸如此类),您可能必须分发一个实际应用程序(例如,通过 No Touch Deployment 或类似方式的 .Net 应用程序)) 包含一个 Web 浏览器控件,它为您提供 HTML/CSS/JavaScript 环境,但对该环境具有更高的控制.

If you have a genuine reason for actually disabling those actions (some kind of intranet application, that sort of thing), you'll probably have to distribute an actual application (for instance, .Net app via No Touch Deployment or similar) that incorporates a web browser control, which gives you the HTML/CSS/JavaScript environment but with dramatically higher control over that environment.

这篇关于我们可以通过javascript禁用浏览器的按钮(后退/前进/刷新)吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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