如何使用javascript捕获点击iframe
How to capture click on iframe using javascript
如何使用javascript捕获点击iframe
我使用这个代码:
document.getElementsByClassName('pin').contentWindow.document.body.onclick =
function() {
alert("iframe clicked");
}
但是它不能捕获iframe的任何点击。我只能使用javascript。我得到了这个错误"SecurityError: Blocked a frame with origin"
var i = 0;
//i represents the exact node since obtaining node by class name gives array of nodes.
var iframe = document.getElementsByClassName('pin')[i].contentWindow;
或
var iframe = document.getElementById("iframe_id").contentWindow;
iframe.document.body.onmousedown =
function() {
alert("iframe clicked");
}
相关文章:
- 当#在iFrame中使用HTML时,阻止页面移动
- iframe src 使用现有值在单击时添加自动播放=true 参数
- 如何在 iframe 上使用 jquery
- 在iframe中使用jquery-mobile调用html页面
- 在 iframe 中使用 iScroll
- 如何在 iframe 中使用全屏模式
- 在iFrame中使用jQuery不起作用
- 在iframe中使用replace方法的Javascript
- oneror(如果在iframe上使用)不会'我不在ie
- 在子iframe中使用来自父级的jquery
- 如何设置iframe在使用jQuery加载完成后自动平滑滚动到底部
- 如果iframe页面使用_parent target,请在新选项卡中打开iframe
- 在可编辑iframe中使用execCommand()时,如何执行与退格相同的操作
- 在iframe中使用jQuery$
- iframe可以使用Bootstrap进行响应吗
- 在iframe中使用document.write for Scripts时Chrome中的奇怪行为
- 我怎么能通过我的referer从当前页面到iframe不使用php
- 在iframe中使用javascript的想法/技巧
- fangating在facebook iframe标签使用任何其他PHP
- 在iframe中使用父文档中的对象