触发对iframe的点击不起作用 [英] triggering click on iframe did not work
问题描述
查看此小提琴: http://jsfiddle.net/GxPmU/
我尝试在该iframe上绑定click事件,但是,单击iframe并不会相应地触发click事件
I tried to bind a click event on that iframe, however, clicking on the iframe does not trigger the click event accordingly
此外,firebug控制台还会输出错误:
moreover the firebug console also outputs errors:
Error: Permission denied to access property 'nodeType'
[Break On This Error]
if ( selector.nodeType ) {
您知道我做错了什么以及如何能够相应地在iframe上绑定click事件吗?
Any idea what I did wrong and how to be able to bind the click event on the iframe accordingly?
推荐答案
从"相同出处政策",您将无法获得点击事件.
As of the "Same origin policy" you can't get the click event.
我已经创建了一个演示来展示这种行为.第一个链接来自相同的来源,因此点击被传递.另一方面,第二个则没有响应:
I've created a demo to show this behavior. The first link is on the same origin and therefor the click is passed. The second one on the other hand does not response:
HTML
<iframe id="iframe-test-1" src="jsfiddle.net/404"></iframe>
<iframe id="iframe-test-2" src="http://jsfiddle.net/404"></iframe>
演示
这篇关于触发对iframe的点击不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!