为iframe添加onclick和onmousemove事件

代码结构如下,具体的已省略
图片说明
要在home.html为iframe添加onclick和onmousemove事件,而不是在main.html(因为iframe的src会根据侧边栏而改变)
拜托各位大神帮忙,谢谢~~

试试

 document.querySelector('iframe').onload = function() {
    var iframeWindow = document.querySelector('iframe').contentWindow
    iframeWindow.document.body.onclick = function() {
        console.log(1);
    }
    iframeWindow.document.body.onmousemove = function() {
        console.log(2);
    }
}

http://blog.csdn.net/u011151452/article/details/52353566