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

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

问题描述

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

有什么办法由JavaScript来禁用浏览器(IE专)BACK键,前进按钮,刷新按钮。这样一来,当过任何用户会点击任何按钮,什么都不会发生。

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的kiosk模式允许后退,前进和刷新(通过键盘快捷键)。

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

在实际网页(一个真正的首页输出在网络上),禁用后退/前进/刷新当然会的非常的不当行为,我认为这不是你想要做什么。 (相反,使用历史库和这样保证你的页面/ Web应用程序实际工作的的后退和前进按钮做用户所期待的。)

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应用程序中,诸如此类的事情)真正的原因,你可能要通过无接触部署或类似的分发实际应用中(例如,.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天全站免登陆