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);
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。