Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top