Solve the method of jquery.resize () execution multiple times in IE browser

Source: Internet
Author: User

The resize () event provided by jquery was recently used in the foreground effect. Resize
This event is to monitor the browser window zoom in and out, that is, the size of the browser window changes.


I provided an example when I consulted the W3cschool. The source



  1. <</SPAN>html>

  2. <</SPAN>head>

  3. <</span>script type= "Text/javascript" src= "/jquery/jquery.js" ></</SPAN>script>

  4. <</span>script type= "Text/javascript" >

  5. x=0;

  6. $ (document). Ready (function () {

  7. $ (window). Resize (function () {

  8. $ ("span"). Text (x+=1);

  9. });

  10. $ ("button"). Click (function () {

  11. $ (window). Resize ();

  12. });

  13. });

  14. </</SPAN>script>

  15. </</SPAN>head>

  16. <</SPAN>body>

  17. The size of the <</SPAN>p> window is adjusted <</SPAN>span>0</</SPAN>span> times. </</SPAN>p>

  18. <</SPAN>p> try resizing your browser window. </</SPAN>p>

  19. <</SPAN>button> Resize events for trigger window </</SPAN>button>

  20. </</SPAN>body>

  21. </</SPAN>html>
As a result I zoomed in on the IE Environment Window resize event executed two times. Later I in Google and Baidu above query, there are two times in the IE environment to carry out the relevant information. Finally found a very good solution. A foreign askew has written a plugin specifically for the jquery.resize () event enhancement. The address is here: http://benalman.com/projects/jquery-resize-plugin/add "jquery.ba-resize.js" after adding jquery.js.  



    1. <</SPAN>html>

    2. <</span>title>jquery-resize () </</SPAN>title>

    3. <</SPAN>head>

    4. <</span>script type= "Text/javascript" src= "Js/jquery.js" ></</SPAN>script>

    5. <</span>script type= "Text/javascript" src= "Js/jquery.ba-resize.js" ></</SPAN>script>

    6. <</span>script type= "Text/javascript" >

    7. x=0;

    8. $ (document). Ready (function () {

    9. $ (window). Resize (function () {


    10. $ ("span"). Text (x+=1);
    11. });



    12. });

    13. </</SPAN>script>

    14. </</SPAN>head>

    15. <</SPAN>body>

    16. <</SPAN>p> window size has been adjusted <</SPAN>span>0</</SPAN>span> times. </</SPAN>p>

    17. <</SPAN>p> Please try resizing the browser window again. </</SPAN>p>

    18. </</SPAN>body>

    19. </</SPAN>html>

Solve the method of jquery.resize () executing multiple times in IE browser (GO)

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.