javascript - $(window).resize() in safari : why it works also if scroll window (but doesn't resize)? -


i noticed, safari on iphone5

$(window).resize() 

it works strangely...

i have code:

$(document).ready(function () {  $(window).resize(function() {      avviachart();      initialize();      if($('#time').is(':checked')){           $("#time").removeattr('checked');          $("#time").css('border','2px solid #ffffff');      }     });    }); 

this code should work when sizes of window change.... other browser work good, safari code works if scroll page (and sizes of window doesn't change)...

how possible ? o.o

this known bug happened ios6 safari. resize event fires randomly while scrolling. fortunately it's not jquery issue.

this answer similar problem might solve issue well.

for lazy:

3stripe posted should "store window width , check has changed before proceeding $(window).resize function"

his code snippet:

jquery(document).ready(function($) {      /* store window width */     var windowwidth = $(window).width();      /* resize event */     $(window).resize(function(){         // check if window width has changed , it's not ios triggering resize event on scroll         if ($(window).width() != windowwidth) {              // update window width next time             windowwidth = $(window).width();              // stuff here          }          // otherwise nothing      });  }); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -