zoukankan      html  css  js  c++  java
  • 异步操作执行后子页面重新修改父页面iframe高度

    子页面加入ajax全局方法:

    <script language="javascript" type="text/javascript">
            $(document).ready(function () {//异步请求加载完成
                $.ajaxSetup({
                    'complete': function () {
                        //修改iframe高度
                        reSizeParentIframe();
                    }
                });
            });        
        </script>

    修改iframe高度:

    //子页面重新修改父页面iframe高度
    function reSizeParentIframe() {
        var realHeight = 0;
        if (navigator.userAgent.indexOf("Firefox") > 0 || navigator.userAgent.indexOf("Mozilla") > 0 || navigator.userAgent.indexOf("Safari") > 0 || navigator.userAgent.indexOf("Chrome") > 0) { // Mozilla, Safari,Chrome, ...  
            realHeight = window.document.documentElement.offsetHeight + 35; 
        } else if (navigator.userAgent.indexOf("MSIE") > 0) { // IE  
            var bodyScrollHeight = window.document.body.scrollHeight + 21; //取得body的scrollHeight  
            var elementScrollHeight = window.document.documentElement.scrollHeight + 1; //取得documentElement的scrollHeight  
            realHeight = Math.max(bodyScrollHeight, elementScrollHeight); //取当中比较大的一个  
        } else {//其他浏览器  
            realHeight = window.document.body.scrollHeight + window.document.body.clientHeight + 1;
        }
        if (realHeight < 400) {
            realHeight = 400;
        }
        if ($("#ifm", window.parent.document).is("iframe")) {
            $("#ifm", window.parent.document).height(realHeight);
        }
    }
  • 相关阅读:
    CompletableFuture使用
    ThreadLocal(Java)
    Java多线程高并发(读写锁ReentrantReadWriteLock)
    Java post和get请求的封装(copy直接用)
    Java多线程死锁举例
    Java Socket分发服务负载均衡
    CountDownLatch倒计时器
    Java数据结构(线性表-->顺序表简单实现)
    JavaFuture模式
    matplotlib总结
  • 原文地址:https://www.cnblogs.com/shenyixin/p/2943892.html
Copyright © 2011-2022 走看看