自动适应Iframe
function iframeAutoFit()
{
try
{
if(window!=parent)
{
var a = parent.document.getElementsByTagName("IFRAME");
for(var i=0; i<a.length; i++) //www.deepteach.com
{
if(a[i].contentWindow==window)
{
var h = document.body.scrollHeight;
if(document.all) {h += 4;}
if(window.opera) {h += 1;}
a[i].style.height = h;
}
}
}
}
catch (ex)
{
alert("脚本无法跨域操作!");
}
}
//在子页面中增加
if(document.attachEvent)
window.attachEvent("onload", iframeAutoFit);
else
window.addEventListener('load', iframeAutoFit, false);
{
try
{
if(window!=parent)
{
var a = parent.document.getElementsByTagName("IFRAME");
for(var i=0; i<a.length; i++) //www.deepteach.com
{
if(a[i].contentWindow==window)
{
var h = document.body.scrollHeight;
if(document.all) {h += 4;}
if(window.opera) {h += 1;}
a[i].style.height = h;
}
}
}
}
catch (ex)
{
alert("脚本无法跨域操作!");
}
}
//在子页面中增加
if(document.attachEvent)
window.attachEvent("onload", iframeAutoFit);
else
window.addEventListener('load', iframeAutoFit, false);