设置iframe的高度兼容问题
fisea 2013-10-17 03:12:13 code如下:
function dynAdjustiframesize(iframename) {
var iframe = null;
if (document.getElementById) {
iframe = document.getElementById(iframename);
}
else {
eval('iframe = ' + iframename + ';');
}
//begin resizing iframe
iframe.style.display = "block"
if (iframe.Document) {//ie自有属性scrollHeight
//iframe.height = iframe.contentDocument.body.scrollHeight;
iframe.height = iframe.Document.body.scrollHeight;
} else if (iframe.contentDocument) {//ie,firefox,chrome,opera,safari
if (whichBrs() == "Firefox") {
iframe.height = iframe.contentDocument.documentElement.offsetHeight;
}
else { //safari
iframe.height = iframe.contentDocument.documentElement.scrollHeight;
}
}
}
问题:
就是在IE里面有问题。
iframe.height = iframe.Document.body.scrollHeight;
IE9以上是ok的(iframe.height为0)。但是切换到IE7/IE8 就是 iframe.height=19了,请告诉指点下。
谢谢