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

JS 控制框架高度自适应浏览器:

框架主页面代码如下:

   <body>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td width="8" bgcolor="#353c44">
                &nbsp;
            </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">
                &nbsp;
            </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">
                &nbsp;
            </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() 获取页面高度

    

你可能感兴趣的:(浏览器,height)