IE6 Browser The Resize event was executed several times to resolve the basics

Source: Internet
Author: User
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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.