继续探讨“关于iframe自动根据里面文件内容高和宽来判断irame的高和宽问题”

某鸟 2002-08-27 12:17:49
http://211.157.102.21/expert/topic/839/839033.xml?temp=.225094
只有IE支持document.all的写法。

那么就没有通用的解决方法了吗???
我找到了一个,可是有点问题,
window.resizeTo(document.body.scrollWidth+10,document.body.scrollHeight+10);
如果页面长的话,则可正常工作,但是当点了一个长页面之后再点一个短页面的话,
iframe缩不回来了,还是刚才那么长……,
我用了这个……
function ()
{
if((document.body.scrollHeight + 30)>421)
//window.resizeTo(document.body.scrollWidth+10,document.body.scrollHeight+10);
parent.document.all.interface.height=document.body.scrollHeight + 30;
else
parent.document.all.interface.height=421;
}
可以解决,可是听说这个不太通用,换成注释里面的那个resizeto吧,
对于这个问题又不好使……
...全文
86 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
孟子E章 2002-08-27
  • 打赏
  • 举报
回复
test.htm
=================
<select onchange="document.frames('mxh').location=this.options[this.options.selectedIndex].value">
<option value="a.htm">a.htm<option value="b.htm">b.htm
</select>
<br>
<iframe name=mxh id=mxh height=2></iframe>

a.htm
================
<body topmargin=0 onload="parent.document.all['mxh'].height=document.body.scrollHeight+10">
<p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p><p>test</p>

b.htm
============
<body onload="parent.document.all['mxh'].height=document.body.scrollHeight+10">
<p>test</p>

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧