iframe监听鼠标点击事件

需要实现的页面逻辑是:
在父页面点击iframe层,点击时间生效

先构造页面文档结构:


   
       


       
       
   

 

var iframe = document.getElementById('my-iframe');
iframe.onload = function() {
    iframe.contentDocument.onclick = function () {

      console.log('iframe内的点击事件生效了')
    };
}

 

文章转自  https://blog.csdn.net/sxqlmc000/article/details/70741585

你可能感兴趣的:(iframe监听鼠标点击事件)