Why does IE8 hangs on jquery window.resize event?

I discovered a problem that seems to reproduce always when opening a piece of html and javascript in IE8.

<html>
    <body>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
    <script>
        $(document).ready(function(){
            $(window).resize(function() {
                console.log('Handler for .resize() called');
            });
        });
    </script>
    <div id="log">
    </div>
    </body>
</html>

Loading this file in IE8 and opening Developer Tools will show that the log message is printed continuously after one resize of the browser window.

Does anyone has an idea why? This is not happening in IE7 or IE9, nor in other browsers (or at least their latest versions).

UPDATE

One solution to prevent the continuos trigger of resize() is to add handler on document.body.onresize if the browser is IE8.

 var ieVersion = getInternetExplorerVersion();
    if (ieVersion == 8) {
        document.body.onresize = function () {
        };
    }
    else {
        $(window).resize(function () {
        });
    }

But this does not answer my question: is the continuous firing of resize() a bug in IE8?

6
задан Vasile Tomoiaga 12 May 2011 в 05:24
поделиться