禁用iframe中的JavaScript按键事件 [英] Disable JavaScript keypress events in iframes

查看:815
本文介绍了禁用iframe中的JavaScript按键事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在iframe中禁用对JavaScript keypress事件的支持?

How do I disable the support for JavaScript keypress events in iframes?

我只需要在特定的iframe中禁用keypress事件,因此执行catch-all-events-并且没有做任何解决方案。

I need keypress events disabled only in specific iframes, so doing a catch-all-events-and-make-em-do-nothing solution is not an option.

推荐答案

这是示例可以满足您的需求吗?

Does this example does what you want ?

根据这个线程,沿线的东西of:

According to this thread, something along the line of:

document.getElementById('edit').contentWindow.addEventListener('keypress', cK, true);

帮助捕获给定iframe中的按键。如果可以捕获它们,则可以禁用它们。

helps capturing keypress in a given iframe. If they can be captured, they can be disabled.

警告:正如 Allain Lalonde 在评论中:


如果iframe的内容不是来自其他域,这将有效。

This will work if the iframe's content isn't from another domain.

这篇关于禁用iframe中的JavaScript按键事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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