主页
<td id=iHeight>框架页
<body onload="parent.document.all.iHeight.height=this.document.body.scrollHeight+10;">
<td id=iHeight>框架页
<body onload="parent.document.all.iHeight.height=this.document.body.scrollHeight+10;">
这句话,有的时候可以显示,怎么有的时候是提示“拒绝访问”,有没有更好的法子,(子页面、主页面我都可以修改)
不是你的
onload="window.resizeTo(document.body.scrollWidth+10,document.body.scrollHeight+10);"父页插入iframe的表格的<td id=iHeight>
你的是远程调用吗?
我的父页面:
<table width=500 border=1>
<tr><td id=iHeight><iframe width="100%" scrolling="NO" frameborder=0 name=ifs id=ifs src="http://远程地址/iframe1.html">
</iframe></td></tr></table>子页面:
<body onload="parent.document.all.iHeight.height=this.document.body.scrollHeight+10;">
<table width="294" border="0" cellspacing="0" cellpadding="0">可是不行啊!
行:14
字符:1
错误:拒绝访问。
代码:0
URL: http://远程地址/iframe1.html
function iframeAutoFit()
{
if(self!=top && window.name=="mainFrame")
{
var iframe = parent.document.getElementById(window.name);
if(iframe)
{
iframe.parentNode.style.height = iframe.style.height;
iframe.style.height = 10;
var h = document.body.scrollHeight;
var minimalHeight = 423;
h = h<minimalHeight ? minimalHeight : h;
if(window.navigator.appName == "Microsoft Internet Explorer"
&& iframe.frameBorder=="1") h += 4;
iframe.parentNode.style.height = iframe.style.height = h;
}
else alert("Iframe's id unequal to iframe's name!");
}
}
if(document.attachEvent)
{
window.attachEvent("onload", iframeAutoFit);
}
else window.addEventListener('load', iframeAutoFit, false);
</script>