久艹网,亚洲一日韩欧美中文字幕2019,国产欧美日韩精品专区黑人,一区二区三区久久99

中山php|最優(yōu)網(wǎng)絡(luò)中山做網(wǎng)站 中山php建站

最優(yōu)良人

2011/08/28 at 15:46

讓框架iframe高度自適應(yīng),可自動撐開高度

默認iframe框架是不能撐開高度的,如果需要讓框架高度自適應(yīng)需要用js實現(xiàn)
js代碼:
var adjustIframe = function (id) {
var iframe = document.getElementById(id)
var idoc = iframe.contentWindow && iframe.contentWindow.document || iframe.contentDocument;
var callback = function () {
var iheight = Math.max(idoc.body.scrollHeight, idoc.documentElement.scrollHeight); //取得其高
iframe.style.height = iheight + "px";
}
if (iframe.attachEvent) {
iframe.attachEvent("onload", callback);
} else {
iframe.onload = callback
}
}
HTML代碼如下所示:
使用代碼:

window.onload = function(){
adjustIframe("js_sub_web");
}

標(biāo)簽:,
-