您的位置:首页 > Web前端 > JavaScript

如何通过JS控制父级别框架可是高度

2014-10-16 15:36 375 查看
JS 控制框架高度自适应浏览器:
框架主页面代码如下:
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="8" bgcolor="#353c44">
 
</td>
<td width="191" valign="top">
<iframe height="100%" width="100%" border="0" frameborder="0" src="/Common/Left"
name="leftFrame" id="leftFrame" title="leftFrame"></iframe>
</td>
<td width="10" bgcolor="#fff">
 
</td>
<td valign="top">
<iframe width="100%" border="0" frameborder="0" src="/Common/SuppotMain" name="rightFrame"
id="rightFrame" title="rightFrame" overflow-y="auto" overflow-x="none"></iframe>
</td>
<td width="8" bgcolor="#353c44">
 
</td>
</tr>
</table>
</body>

内页改变 rightFrame 框架高度JS代码如下:<script>
function resize() {
$("#rightFrame", window.parent.document).css("height", $(window.parent.window).height());
}
$(document).ready(resize);
$(window.parent.window).resize(resize);
</script>


框架主页面改变 rightFrame 框架高度JS代码如下:
<script>
function resize() {
$("#rightFrame").css("height", $(window).height());
}
$(document).ready(resize);
$(window).resize(resize);

</script>

注:
$(window).height() 获取浏览器可视高度
$(document).height() 获取页面高度

本文出自 “战争之影” 博客,请务必保留此出处http://rmlifejun.blog.51cto.com/7683304/1564822
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: