如何在打开这个页面时得到这个页面的高度?
一个框架面面,包含三个页面
头,左,右三个页面
右面的页面是主显示区会有滚动条,如何让整个框架页有滚动条,而不是单个页面出滚动条。
---------------------------------------------------------------
1<html>
2<head>
3<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
4<meta content="F.R.Huang(meizz梅花雪)//www.meizz.com" name="author"/>
5<title>用 iframe 模拟 frame 使网架网页能够居中</title>
6</head>
7<body leftmargin="0" topmargin="0"><center>
8<table align="center" border="0" cellpadding="0" cellspacing="0" height="100%" width="780">
9<tr><td colspan="2" height="100" width="780">
10<iframe frameborder="1" height="100%" width="100%"></iframe>
11</td></tr>
12<tr>
13<td width="180">
14<iframe frameborder="1" height="100%" width="100%"></iframe>
15</td>
16<td valign="top" width="600"><div style="height: 100%">
17<iframe frameborder="1" height="100%" id="MzMain" name="MzMain" src="用iframe模拟frame子页.htm" width="100%"></iframe>
18</div></td>
19</tr>
20</table>
21</center></body></html>
用iframe模拟frame子页.htm
1<html>
2<head>
3<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
4<meta content="F.R.Huang(meizz梅花雪)//www.meizz.com" name="author"/>
5<title>iframe 自适应其加载的网页(多浏览器兼容)</title>
6<script language="javascript">
7function iframeAutoFit() //author: meizz(梅花雪 20041225)
8{
9if(self!=top && window.name=="MzMain") //这个 name 对应的是 iframe 的 name
10{
11var iframe = parent.document.getElementById(window.name);
12if(iframe)
13{
14iframe.parentNode.style.height = iframe.style.height;
15iframe.style.height = 10;
16var h = document.body.scrollHeight;
17var minimalHeight = parseInt((window.screen.width*11)/16, 10) - 280;
18h = h<minimalHeight ? minimalHeight : h;
19if(window.navigator.appName == "Microsoft Internet Explorer"
20&& iframe.frameBorder=="1") h += 4;
21iframe.parentNode.style.height = iframe.style.height = h;
22}
23else alert("Iframe's id unequal to iframe's name!");
24}
25}
26if(document.attachEvent) window.attachEvent("onload", iframeAutoFit);
27else window.addEventListener('load', iframeAutoFit, false);
28</script>
29</head>
30<body>
31<span style="width: 300; height: 400; background-color: yellow">
32iframe 自适应其加载的网页(多浏览器兼容)
33</span>
34</body>
35</html>