Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox maximize doesn't trigger resize Event

I try to catch resize events with jquery and the

$(window).resize(function() { }

Everything works fine, except when I use the maximize Button in Firefox, the event is not thrown.

Is there something wrong here?

like image 503
spankmaster79 Avatar asked Aug 10 '11 15:08

spankmaster79


People also ask

How do you trigger a resize event?

In your modern browsers, you can trigger the event using: window. dispatchEvent(new Event('resize'));

What happen when window is resized?

The resize event fires when the document view (window) has been resized. This event is not cancelable and does not bubble. In some earlier browsers it was possible to register resize event handlers on any HTML element.

How do I add event listener to window width?

Answer: Use the addEventListener() Method You can simply use the addEventListener() method to register an event handler to listen for the browser window resize event, such as window. addEventListener('resize', ...) . The following example will display the current width and height of the browser window on resize.


2 Answers

Seems not working because it takes a bit to maximize I think, this works for me:

$(window).resize(function() {
  console.log('resize');
  setTimeout(function() {
    console.log('resize me later');
  }, 150);
});
like image 95
lcapra Avatar answered Sep 20 '22 16:09

lcapra


$(window).resize(function() { 
   console.log('resize!');
});

This works in FF5 / osx

like image 28
wesbos Avatar answered Sep 22 '22 16:09

wesbos