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了,请告诉指点下。
谢谢iframe
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了,请告诉指点下。
谢谢iframe
19,好熟悉的一个数字,IE6下有个19px的bug块级元素最小高度不会小于19px,不知道和你这个有没有关系。额,顺便吐槽一下LZ贴的代码。
if(document.getElementById) 这个if至少在现在,没有一个浏览器会返回false,包括IE6。