检测iframe内的点击 [英] detect click inside iframe

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

问题描述

我想检测点击INSIDE iframe没有点击iframe本身我试过onclick事件你必须点击iframe本身触发功能我甚至尝试addeventlistener到窗口或文档没有工作,好像iframe不存在功能永远不会triger时我点击内部iframe :( plz help

i wanna detect click INSIDE iframe not onclick on iframe itself i tried onclick event u must click on iframe itself to trigger function i even tried addeventlistener to window or document nothing work as if the iframe isn't there the function never triger when i click inside iframe :( plz help

推荐答案

仅适用于同一域名的iframe:

Only works on iframes on the same domain:

$('body', $('select-your-iframe-here').contents()).click(function(event) {
  console.log('Clicked! ' + event.pageX + ' - ' + event.pageY);
});

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

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