一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

iframe自适应宽度、高度 ie6 7 8,firefox 3.86

时间:2010-07-30 编辑:简简单单 来源:一聚教程网

 

var temp_iframe
var content = document.getelementbyid('right'); //id为 right的dom容器中,进行创建iframe和宽高自适应
var c = 0;
function append(filename)
{
var the_iframe = "helpfile" + c;
temp_iframe = document.createelement("iframe");
temp_iframe.src = filename;
temp_iframe.scrolling = "no";
temp_iframe.setattribute("frameborder", "0");
temp_iframe.id = the_iframe;
temp_iframe.name = the_iframe;
scroll(0, 0);
content.innerhtml = "";
content.appendchild(temp_iframe);
if (document.all)
{
temp_iframe.attachevent('onload', function()
{
temp_iframe.setattribute("width", window.frames[the_iframe].document.body.scrollwidth); //自适应宽
temp_iframe.setattribute("height", window.frames[the_iframe].document.body.scrollheight); //自适应高
});
}
else
{
temp_iframe.addeventlistener('load', function()
{
temp_iframe.setattribute("width", window.frames[the_iframe].document.body.scrollwidth);
temp_iframe.setattribute("height", window.frames[the_iframe].document.body.scrollheight);
}, false);
}
c++;
return false;
}

/*调用方法
把此脚本另存为脚本文件:iframe.网页特效,然后再前台页面中调用:
------------------------------------------------------------------------




------------------------------------------------------------------------
或者 去掉脚本中最后的 return false,前台:
------------------------------------------------------------------------

网页特效:append('favorite/favorites.html')" class="li1">


------------------------------------------------------------------------
*/

热门栏目