使用 css 或 jQuery 阻止页面响应事件
我知道标题有点令人困惑,但我不太确定如何表达我的问题。
我的网站 - http://gx61design.com - 有一个在加载时显示的警报框,我需要将其设为某种模式框,这样当它显示时,您就无法像现在一样使用箭头键或将鼠标悬停在页面中的元素上
The title is a bit confusing I know but I wasnt quite sure how to word my question.
my site -- http://gx61design.com -- has a alert box that shows up onLoad I need to make it a sort of modal box so that when it shows up you cannot use the arrow keys or hover over the elements in the page like you can at the moment
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我们在当前的项目中使用 jQuery UI - 对话框。 模态对话框会抛出一个掩码,阻止与下面的页面交互,直到用户单击按钮或关闭对话框窗口。
非常容易使用!
We use jQuery UI - Dialogs in our present project. The modal dialog throws up a mask that will prevent interaction with the page underneath until the user clicks a button or dismisses the dialog window.
Very easy to use!
您可以设置一个全局变量来查看用户是否关闭对话框并取消箭头事件,直到用户关闭对话框。因此,使用页面中的代码:
或者您可以直接将按键绑定函数放入 apprise 回调函数中:
You can set up a global variable to see if user dismissed a dialog and cancel arrow events until a user dismisses the dialog box. So using the code from your page:
or you could put the key binding function in the apprise callback function directly:
基本思想是在页面上放置一个(半)透明的
div
,并将模式对话框放在顶部。 jqModal 插件是我所知道的最简单的脚本,可以为您完成此操作。不管怎样,这些被称为“模式对话框”,谷歌搜索会找到无穷无尽的资源。
The basic idea is to put a (semi)-transparent
div
over your page with the modal dialog on top. The jqModal plugin is the simplest script I know of that does this for you.Anyways, these are called "modal dialogs" and googling will turn up endless resources.
您可以使用 JQuery 轻松地做到这一点。使用 jquery 模型对话框并将
model
选项设置为true
。http://jqueryui.com/demos/dialog/#modal
You can easily do this with JQuery. Use jquery model dialog and set the
model
option totrue
.http://jqueryui.com/demos/dialog/#modal