offset()。顶不在IE7中工作?

时间:2012-05-16 15:52:26

标签: javascript internet-explorer-7 cross-browser

过去几个小时我一直在努力解决JS问题,我想知道你们中的一位优秀程序员是否可以找到解决方案。

这是我的代码:

var topfooter = $('footer').offset().top;
$('#skylandscape').css('height', newlandscapeheight);
console.log('New landscape height is ' + newlandscapeheight + ' (topfooter top is '+ topfooter +')');

这适用于我使用的几乎所有浏览器(最新的chrome,safari,ff,opera)和IE8 +,但不适用于IE7。有谁看到可能是什么问题以及如何解决它?

代码获取我的页脚的总高度(100%widthed图像),并设置我的页面的第一个块的高度,页脚没有使用的任何空间。

非常感谢提前。 纪尧姆。

2 个答案:

答案 0 :(得分:0)

尝试:

var topfooter = document.getElementById('footer').offsetTop;

答案 1 :(得分:0)

您使用ID为“页脚”的div,如果是这样,请执行以下操作:

var topfooter = $('#footer').offset().top;