溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

iframe自適應高度 url

發布時間:2020-07-10 23:41:19 來源:網絡 閱讀:395 作者:pmlinjian 欄目:開發技術

iframe自適應高度 url

http://caibaojian.com/iframe-adjust-content-height.html

.new-ico {display: block; width: 27px; height: 28px;

            background: url(static/img/new.png) 0 center no-repeat;

            position: absolute; left: 10px; top: 20px;;

        }

<i class="new-ico"></i>


//iframe自適應高度

function reinitIframe(){

var iframe = document.getElementById("iframe_box");

try{

var bHeight = iframe.contentWindow.document.body.scrollHeight;

var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;

var height = Math.max(bHeight, dHeight);

iframe.height =  height;

}catch (ex){

}

}

window.setInterval("reinitIframe()", 2629);


////////////////2////////////


var iframeHeight = 0;

var addIframeHeight = 0;


//調整iframe高度

function adjustIframe(){

try{

var h = 0 , fr = $("#frame")[0];

if(fr.contentDocument && fr.contentDocument.body.offsetHeight){

h = fr.contentDocument.body.offsetHeight; 

document.title = fr.contentDocument.title;

}else if (fr.Document && fr.Document.body.scrollHeight){

h = fr.Document.body.scrollHeight;

document.title = fr.Document.title;

}

if(h != iframeHeight){

//fr.height = h + 35;

iframeHeight = h;

fr.height = h + addIframeHeight;

}

}catch(e){}

};

//重新調整iframe高度,主要用于臨時增加或減少頁面的高度

function reAdjustIframe(addHeight){

iframeHeight = 0;

addIframeHeight = addHeight;

adjustIframe();

addIframeHeight=0;

}

setInterval(function(){

adjustIframe();

},300);


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女