Principle: Listening window
events load
.
// 等待网页完成加载
window.addEventListener('load', function() {
// 加载完成后执行的代码
}, false);
Note: It is best to put the monitoring code in the outermost layer, not in the function, so that it can be executed immediately after the page is loaded. Of course, there are special needs, adapt to the situation.