IE8中的参数无效

Jon*_*sen 2 html javascript jquery invalid-argument

这让我困惑了好几个小时了.为什么在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
        });
    });
}
Run Code Online (Sandbox Code Playgroud)

我得到的确切错误是:

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

Rob*_*b W 5

window.innerHeight没有定义现有IE,那么wHeight就是undefined,和fullPadNaN.试试吧$(window).height() .

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