The window. resize event is triggered when a DOM node is dynamically added to IE.

Source: Internet
Author: User

Then there are several events on the page that dynamically add DOM elements. For example, clicking a layer will list the details of this layer, so there is no problem in FF and chrome, but in the IE6-8 every time re-layout.

For example, when I drag a layer, the content in the middle layer is displayed at the bottom. When I open the layer, the layer jumps back to the position before the drag...

At first, I didn't see that it was a re-layout... then I demonstrated N for a long time, struggled N for a long time, and finally thought it was possible that the window was triggered due to the dynamic addition of DOM nodes. resize and re-layout the page...

Finally, I couldn't help shouting "Thank godness...". Fortunately, changing the height of the window has no effect on the page layout. Otherwise, it will be annoying...

Copy codeThe Code is as follows:
BindResizeWindow: function (){
Var obj = this;
$ (Window). resize (function (){
Var newWidth = $ (window). width ();
If (newWidth = obj. Required wwidth) {return ;}
Obj. initUI ();
Obj. createUI ();
Obj. Required wwidth = newWidth;
});
},


You only need to determine in the binding method that the re-layout event is triggered only when the width is changed...

Related Article

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.