📜  将 eventlistener 应用于 iframe - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:25.140000             🧑  作者: 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');
                });
};