iframe loaded event

Disclaimer: This article is a blogger original article, please indicate the source. https://blog.csdn.net/qq_42968609/article/details/85162447

Project optimization, you need to add loading when requesting data, the old project using iframe, request returns a nested page, be treated in the iframe's onload event.

iframe's onload event code sample:

var iframe = document.getElementById("commandIframe");
if (iframe.attachEvent){ // 兼容IE写法
	iframe.attachEvent("onload", function(){
		// iframe加载完成后要进行的操作
	})
} else {
	iframe.onload = function(){
		// iframe加载完成后要进行的操作
	}
}

IE support iframe's onload event, but is invisible, it is necessary to register by attachEvent.

Guess you like

Origin blog.csdn.net/qq_42968609/article/details/85162447