js监听iframe是否加载完毕

js监听iframe是否加载完毕

代码片.

//初始化加载

        var a = document.getElementById(id);
        var iframeLoad = function () {
            window.setTimeout(function() {
               console.log("加载完毕")
            }, 100);
            //移除监听器
            a.removeEventListener("load", iframeLoad, true);
        };
        a.addEventListener('load', iframeLoad, true);
    })
}

猜你喜欢

转载自blog.csdn.net/qq_42267888/article/details/101512874