📌  相关文章
📜  如何将事件侦听器添加到 iframe - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:21.396000             🧑  作者: Mango

代码示例2
var iframe = document.getElementsByTagName('iframe')[0],
    iDoc = iframe.contentWindow     // sometimes glamorous naming of variable
        || iframe.contentDocument;  // makes your code working :)
if (iDoc.document) {
    iDoc = iDoc.document;
    iDoc.body.addEventListener('afterLayout', function(){
                        console.log('works');
                });
};