IE7 browser window Size change events perform multiple bugs and IE6/IE7/IE8 resize problems _jquery

Source: Internet
Author: User

This article mainly through the code example to introduce the IE7 browser window size Change event to perform many bugs and ie6/ie7/ie8 under the resize problem, step-by-step introduction, first to introduce IE7 browser window size Change event to perform multiple bugs, specific problem analysis and solutions please see below.

var resizetimer = null;
$ (window). Resize (function () {
 if (resizetimer) cleartimeout (resizetimer);
 Resizetimer = settimeout ("alert (' mm ')";
});

There is also a parity to determine the variables to solve (feel this method is also OK)

The code is as follows:

var n=0;
$ (window). Resize (function () {
 if (n%2==0) {
  alert ("mm");
 }
 n++;
});

Whether the jquery package or JS native will produce this bug

IE6/IE7/IE8 jquery Resize Event Execution multiple solutions

In the Resize event using jquery found that every time you change the browser window large hours resize time will be performed two times, Baidu search for a way to find a solution,

Use settimeout to solve this problem code as follows:

var resizetimer = null;
$ (window). Resize (function () {
 if (resizetimer) cleartimeout (resizetimer);
 Resizetimer = settimeout ("alert (' mm ')";
});

There is also a solution by judging the parity of the variable (feeling this method is also OK), the code is as follows:

var n=0;
$ (window). Resize (function () {
 if (n%2==0) {
  alert ("mm");
 }
 n++;
});

The above is this article for IE7 browser window size Change event to perform many bugs and ie6/ie7/ie8 under the resize problem, I hope to help.

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.