如何在iframe的name不定时,根据被包含页面大小动态改变iframe的大小?

秋水无痕:

1<script language="javascript">   
2function toppage()   
3{   
4if (self.location!=top.location)frameElement.height=document.body.scrollHeight + 30;   
5}   
6</script>
 1<body onload="toppage()">   
 2  
 3frameElement地用法,可见   
 4http://www.blueidea.com/bbs/newsdetail.asp?id=442170   
 5但frameElement只有在IE5.5以上支持。   
 6  
 7  
 8根据秋水的提示,我在看了   
 9http://www.blueidea.com/bbs/newsdetail.asp?id=340771   
10后知道了完美的解决办法。   
11  
12<script language="javascript">   
13<!--   
14function toppage()   
15{   
16if (self.location!=top.location)   
17{   
18parent.document.all(self.name).height=document.body.scrollHeight + 30;   
19  
20}   
21}   
22\-->   
23</script>
24<body onload="toppage()">   
25  
26IE5.0测试通过,IE4没法试了,不过还用IE4的非常少了,基本可以不考虑。</body></body>
Published At
Categories with Web编程
comments powered by Disqus