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?
In your modern browsers, you can trigger the event using: window. dispatchEvent(new Event('resize'));
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.
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.
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);
});
$(window).resize(function() {
console.log('resize!');
});
This works in FF5 / osx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With