多层iframe不出现滚动条

  //第一个iframe
 <iframe style="overflow: auto;" id="myframe" name="myframe" frameborder="0"  scrolling="no" width="100%" onload="setIframeHeight(this)">
    //第一个iframe的方法,目的自动跳转iframe的高度
    function setIframeHeight(iframe) {
	    if (iframe) {
		    var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow;
		    if (iframeWin.document.body) {
			    iframe.height = iframeWin.document.documentElement.scrollHeight ||             
                iframeWin.document.body.scrollHeight;
		    }
	    }
    };

    window.onload = function () {
	    setIframeHeight(document.getElementById('external-frame'));
    };
    
    //第二个iframe
    <iframe id="tab1If" scrolling="no" style="overflow:auto;min-        
            height:450px;width:100%;border:none;" src="/home.jsp" >

        //子页面重新修改父页面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; 
            var elementScrollHeight = window.document.documentElement.scrollHeight + 1; 
            realHeight = Math.max(bodyScrollHeight, elementScrollHeight); 
        } else {//其他浏览器  
            realHeight = window.document.body.scrollHeight +     
                            window.document.body.clientHeight + 1;
        }
        if (realHeight < 450) {
            realHeight = 450;
        }
        if ($("#myframe", window.parent.document).is("iframe")) {
            $("#myframe", window.parent.document).height(realHeight);
        }
        }

        function setIframeHeight(reHeight) {
	    var iframe = document.getElementById('tab1If')
	    if (iframe) {
		    var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow;
		    if (iframeWin.document.body) {
			    iframe.height = reHeight;
		    }
	    }
	    reSizeParentIframe()

        };
    </iframe>

</iframe>

//最底层的home.jsp的代码
//子页面重新修改父页面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; 
        var elementScrollHeight = window.document.documentElement.scrollHeight + 1; 
        realHeight = Math.max(bodyScrollHeight, elementScrollHeight); //取当中比较大的一个  
    } else {//其他浏览器  
        realHeight = window.document.body.scrollHeight +     
            window.document.body.clientHeight + 1;
    }
    if (realHeight < 450) {
        realHeight = 450;
    }
    //调用父页面的方法
    parent.setIframeHeight(realHeight);
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值