iframe框架加载完成后执行行为

var iframe = document.getElementById("content");
			iframe.src = "../html/" + pageName;
			$(iframe).hide();
			if (iframe.attachEvent){
			    iframe.attachEvent("onload", function(){
			    	//要指定的行为
			    	$(iframe).show();
			        console.log("Local iframe is now loaded.1");
			    });
			} else {
			    iframe.onload = function(){
			    	//要指定的行为
			    	$(iframe).show();
			    	console.log("Local iframe is now loaded.2");
			    };
			}

iframe执行后加载行为,上面的代码表示iframe加载新的page页面完成后,再显示页面,避免了加载过程中的闪烁(尤其vue会闪烁)。

猜你喜欢

转载自blog.csdn.net/u011628753/article/details/111385510