设置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了,请告诉指点下。
谢谢
...全文
112 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
l676331991 2013-10-18
  • 打赏
  • 举报
回复
0 19?什么意思? 19,好熟悉的一个数字,IE6下有个19px的bug。。。块级元素最小高度不会小于19px,不知道和你这个有没有关系。 额,顺便吐槽一下LZ贴的代码。 if(document.getElementById) 这个if至少在现在,没有一个浏览器会返回false,包括IE6。
fisea 2013-10-18
  • 打赏
  • 举报
回复
没有人知道吗,自己顶起。

87,992

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧