In the IE browser, a resize event is executed multiple times, which is a widely recognized problem in IE6 and IE7. This problem varies with the browsers of the two versions, generally, IE6 is worse than IE7. Next we will introduce the solution. For more information about the solution, see the resize event executed multiple times in IE browser. This is a widely recognized problem between IE6 and IE7. This problem varies with the two versions of browsers. Generally, IE6 is worse than IE7.
Now we have a better solution. Let jquery. wresize. js, The jquery plug-in, help you:
Js Code
The Code is as follows:
/*
========================================================== ========================================================
WResize is the jQuery plugin for fixing the IE window resize bug
........................................ .......................................
Copyright 2007/Andrea Ercolino
-------------------------------------------------------------------------------
LICENSE: php "> http://www.opensource.org/licenses/mit-license.php
WEBSITE: http://noteslog.com/
========================================================== ========================================================
*/
(Function ($)
{
$. Fn. wresize = function (f)
{
Version = '1. 1 ';
Wresize = {fired: false, width: 0 };
Function resizeOnce ()
{
If ($. browser. msie)
{
If (! Wresize. fired)
{
Wresize. fired = true;
}
Else
{
Var version = parseInt ($. browser. version, 10 );
Wresize. fired = false;
If (version <7)
{
Return false;
}
Else if (version = 7)
{
// A vertical resize is fired once, an horizontal resize twice
Var width = $ (window). width ();
If (width! = Wresize. width)
{
Wresize. width = width;
Return false;
}
}
}
}
Return true;
}
Function handleWResize (e)
{
If (resizeOnce ())
{
Return f. apply (this, [e]);
}
}
This. each (function ()
{
If (this = window)
{
$ (This). resize (handleWResize );
}
Else
{
$ (This). resize (f );
}
});
Return this;
};
}) (JQuery );
For more information, see test page.:
Js Code
The Code is as follows:
Test window resize