准确地捕捉对iframe的点击 [英] Accuratly catch clicks on an iframe

查看:117
本文介绍了准确地捕捉对iframe的点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的广告iframe正在动态写入我的页面。里面的广告可能会有另一个iframe本身,并会吸点击事件,因此无法轻松跟踪它们。我过去曾使用@Vince这个伟大的插件:



https://github.com/finalclap/iframeTracker-jquery



这似乎工作正常,直到窗口这是所有运行在IS它的iframe和焦点位于最外面的页面上。我可以看到它获得了滚动/展开事件,但它不会获得点击,除非焦点位于第一个iframe窗口内。



有没有人找到了一种可靠的方法做这个?如果有人能提供帮助,请提前致谢。

https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy =nofollow>同一原产地政策。

我的iframeTracker插件使用了一种狡猾的解决方法来检测iframe上的点击,基于鼠标和焦点事件,它们不能用于多个嵌套iframe。


I have an ad iframe being written onto my page dynamically. The advert inside may have another iframe itself and will "suck" click events through into it so cannot track them easily. I've used this great plugin by @Vince in the past:

https://github.com/finalclap/iframeTracker-jquery

which seems to work fine until the window this is all running in IS ITSELF an iframe and focus is somewhere on the outermost page. I can see it getting the rollover/rollout events but it doesn't get the click unless focus is somewhere inside the first iframe's window.

Has anyone found a solid way to do this? Thanks in advance if anyone can help.

解决方案

I think you can't do that using Javascript because of the same origin policy.

My iframeTracker plugin uses a crafty workaround to detect click on iframe, based on mouse and focus events, that simply doesn't work with multiple nested iframes.

这篇关于准确地捕捉对iframe的点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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