2

这让我困惑了几个小时。为什么在 IE8 中测试时出现“无效参数”错误?

function resizeContainer() {
    wHeight = window.innerHeight;
    $('.container').each(function () {
        $(this).animate({
            height: wHeight
        }, 400);
    });
    $('.content').each(function () {
        wHeight = window.innerHeight;
        fullPad = wHeight - $(this).height();
        if (wHeight < 750) {
            cropFactor = 1.7;
        }
        else {
            cropFactor = 2;
        }
        $(this).animate({
            paddingTop: fullPad / cropFactor
        });
    });
}

我得到的确切错误是:

无效的论点。jquery.js,第 8826 行字符 5

4

1 回答 1

5

window.innerHeight在 IE 之前没有定义,所以wHeightundefined,然后fullPad变成NaN。试试$(window).height() 吧。

在 IE 中设置无效的样式值是“无效参数”错误的原因之一。

于 2012-06-25T12:39:14.333 回答