문제

this has baffled me for a couple of hours now. Why do i get a 'Invalid Argument' error when testing this in 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
        });
    });
}

The exact error im getting is:

Invalid argument. jquery.js, line 8826 character 5

도움이 되었습니까?

해결책

window.innerHeight is not defined prior IE, so wHeight is undefined, and fullPad becomes NaN. Try $(window).height() instead.

Setting invalid style values in IE is one of the causes of the "Invalid argument" error.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top