当 iframe 获得焦点时按下 Esc 键时,Thickbox 不会关闭
当我聚焦 iframe 并尝试按 esc 键关闭窗口时,没有任何反应。我认为这是因为聚焦的 iframe 没有订阅此事件。有谁知道如何将此事件附加到 iframe,而无需手动编辑厚盒中包含的每个页面?
When I focus the iframe and try to push the esc key to close the window, nothing happens. I assume that it is because the focused iframe is not subscribed to this event. Does anyone have any ideas how I could attach this event to the iframe without having to manually edit each one of the pages that are contained in a thickbox?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
该解决方案适用于 Internet Explorer,这恰好是我的客户群使用的唯一浏览器,但我更喜欢至少适用于 Firefox 的解决方案。
我将其添加到原始厚盒源代码的第 245 行。
This solution works in internet explorer, which happens to be the only browser my client base is using, however I would prefer a solution that at least works in firefox.
I add this at line 245 in the original thickbox source.
您是否在 iframe 中运行 Flash?它可能会窃取您的键盘焦点。
Are you running Flash in the iframe? It could be stealing your keyboard focus.
出于安全原因,它不起作用。 iframe 内部发生的任何事件都不允许冒泡到包含的文档中。
It does not work for security reasons. None of the events that happen inside the iframe are allowed to bubble out to the containing document.
我可以通过替换 Thickbox.js 文件的第 245 行来解决这个问题。
刚刚替换:
与
I could solve this problem by replacing the line 245 of the thickbox.js file.
Just replaced:
with
只需将其添加到您的代码中
just add this in your code