页面动态加载Iframe文件
2010-10-28 21:43 ☆冷枫☆ 阅读(7819) 评论(0) 编辑 收藏 举报常常需要在页面中嵌入iframe地址,但通常加载iframe会影响到页面打开速度。js可以动态的嵌入iframe,如果需要也可以在某事件触发时进行相关的操作,从而提高页面响应速度。
js动态加载iframe代码如下:
function LoadIframe(){
var newIframeObject=document.createElement("IFRAME");
newIframeObject.src="http://v.788111.com/v2/video/vodtest.aspx";
newIframeObject.scrolling="no";
newIframeObject.frameBorder=0;
newIframeObject.width=288;
newIframeObject.height=65;
$("feature_info").appendChild(newIframeObject);
}
function $(s) { return document.getElementById(s); };
var newIframeObject=document.createElement("IFRAME");
newIframeObject.src="http://v.788111.com/v2/video/vodtest.aspx";
newIframeObject.scrolling="no";
newIframeObject.frameBorder=0;
newIframeObject.width=288;
newIframeObject.height=65;
$("feature_info").appendChild(newIframeObject);
}
function $(s) { return document.getElementById(s); };
将该函数写在自己需要的事件中,便可实现动态加载的效果。
励志博客园--优秀的阅读、励志、交流学习平台。您的网上心灵家园!