zoukankan      html  css  js  c++  java
  • 根据contentDocument内容的高度调整iframe的高度

    版本一

    <script>
            $(function () {
    
                //根据contentDocument的高度调整menuFrame的高度
                var menuFrame = document.getElementById('menuFrame');
                menuFrame.addEventListener('load', function () {
                    menuFrame.height = 0;
                });
                setInterval(function () {
                    menuFrame.height = getHeight(menuFrame.contentDocument);
                }, 200);
                window.addEventListener('resize', function () {
                    menuFrame.height = 0;
                    menuFrame.height = getHeight(menuFrame.contentDocument);
                });
    
    
            });
    
            function getHeight(doc) {
                if (doc == null) {
                    //menuFrame.height = 1000;
                    return 2000;
                }
    
                var body = doc.body,
                    html = doc.documentElement;
    
                var height = parseInt($('#contentWrapper').css('min-height')) - 15;
                if (body.scrollHeight && body.offsetHeight && html.clientHeight && html.offsetHeight) {
                    height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
                }
                return height;
            }
        </script>
    

    版本二

    <iframe id="menuFrame" name="menuFrame" frameborder="0" style=" 100%; height: 100%; position: absolute;"></iframe>
    
  • 相关阅读:
    3.for in循环
    2.break与continue
    1.XHTML框架结构
    lamda表达式在EF中的应用
    View数据呈现相关技术
    ASP.NET MVC 4 技术讲解
    ASP.NET MVC 相关的社群与讨论区
    C# 随机红包算法
    圆圈里带 小写字母,大写字母
    使用SQL语句 检测 MSSQL死锁
  • 原文地址:https://www.cnblogs.com/vvull/p/14768457.html
Copyright © 2011-2022 走看看