在一个页面中设置iframe的document Onclick 事件获取在iframe中的document被点击的对象,W3C如下:

document.getElementById('iframe的ID').contentDocument.onclikc=function(event){}

以上的EVENT对象在W3C浏览器下可以得到,在IE8中就无法得到,原因有2个,一是IE下的iframe的document对象和W3C不同,二是EVENT对象是根据当前窗口来决定的,如IE下的EVENT对象,是window.event,iframe中就是iframe窗口的event对象而W3C是event到底而不像W3C智能。解决方法如下:

document.getElementById('iframe的ID').contentWindow.document.onclick=function(event){

  var event= document.getElementById('iframe的ID').contentWindow.event;

}

这样就能得到iframe窗口中的document文档点击的对象了。

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2021-11-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-26
  • 2021-06-15
相关资源
相似解决方案