页面高度自适应的浏览器兼容如何解决?


这是我使用的代码

function setHeight(obj) {
var win = obj;
if (document.getElementById) {
if (win && !window.opera) {
if (win.contentDocument && win.contentDocument.body.offsetHeight)
win.height = win.contentDocument.body.offsetHeight;
else if (win.Document && win.Document.body.scrollHeight)
win.height = win.Document.body.scrollHeight;
}
}
}

在IE下显示正常,可是其他的如Chrome FireFox就不行
恳请帮助

浏览器 javaweb JavaScript

小小小次郎 11 years, 10 months ago

`else if (win.Document && win.Document.body.scrollHeight)
win.height = win.Document.body.scrollHeight;
}`

改成

`else if (document.body&&document.body.scrollHeight)
win.height = document.body.scrollHeight;
}`

msz006 answered 11 years, 10 months ago

Your Answer