In IE browser, a Resize event was executed several times. This is a more widely recognized problem with IE6 and IE7, which is different in the two-version browsers, often worse IE6 than IE7.
Now that you have a better solution, let jquery.wresize.js this jquery plugin to help you:
JS Code
Copy Code code 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, a 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);
How to use, please see this example test page:
JS Code
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title> Test Window Resize </title>
<script type= "Text/javascript" src=http://www.hake.cc/kf/201109/"Http://jquery.com/src/jquery-latest.pack.js" ></script>
<script type= "Text/javascript" src=http://www.hake.cc/kf/201109/"Jquery.wresize.js" ></script>
<script type= "Text/javascript" >
JQuery (function ($)
{
function Content_resize ()
{
var w = $ (window);
var H = W.height ();
var W = W.width ();
$ (' #content '). css ({width:w-20, height:h-20});
}
$ (window). Wresize (Content_resize);
Content_resize ();
} );
</script>
<body>
<div id= "Content" style= "border:1px dashed silver; Position:absolute; Overflow:auto; " >
Test test test test test test test test test test test test to be no ST test test test test test test to test test test test test to test Test test test test test test test test test Test "test test" to EST test test test test to test test test test test test to test test to The T test test test test test test test to test test test with test Test test test test test test test test test test test test to be no ST test test test test test test to test test test test test to test Test test test test test test test test test Test "test test" to EST test test testTest test test test test test test test test test test test to be no ST test test test test test test to test test test test test to test Test test test test test test test test test Test "test test" to EST test test test test to test test test test test test to test test to The T test test test test test test test to test test test with test Test test test test test test test test test test test test to be no ST test test test test test test to test test test test test to test Test test test test test test test test test Test "test test" to EST test test testTest test test test test test test test test test test test to be no ST test test test test test test to test test test test test to test Test test test test test test test test test Test "test test" to EST test test test test to test test test test test test to test test to T test test
</div>
</body>