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.js,然后再前台页面中调用:
------------------------------------------------------------------------
------------------------------------------------------------------------
或者 去掉脚本中最后的 return false,前台:
------------------------------------------------------------------------
------------------------------------------------------------------------
*/