我在页面上有一个iframe,来自第三方(广告).我想在点击iframe时发出点击事件(记录一些内部统计数据).就像是:
$('#iframe_id').click(function() {
//run function that records clicks
});
Run Code Online (Sandbox Code Playgroud)
..基于HTML:
<iframe id="iframe_id" src="http://something.com"></iframe>
Run Code Online (Sandbox Code Playgroud)
我似乎无法得到任何变化的工作.思考?
这是我的 iframe:
#htmlDiv {
position: absolute;
top: 0px;
left: 300px;
height: 650px;
width: 1130px;
}
#htmlFrame {
position: absolute;
top: 0px;
left: 0px;
margin: 10px 10px 10px 10px;
padding: 0px 0px 0px 0px;
height: 630px;
width: 1110px;
}
<div id="htmlDiv">
<iframe id="htmlFrame"></iframe>
</div>
$('#htmlFrame').click(function(){
alert('clicked');
});
Run Code Online (Sandbox Code Playgroud)
但是当我在 iframe 内单击时,它不会显示“已单击”。
如何检测 iframe 内的点击。