1

Is it possible to get notified when the browser window size changes? This might happen when the user resizes the browser window etc. I need to resize an element in response to size change,

Thanks

user246114
  • 50,223
  • 42
  • 112
  • 149
  • possible duplicate of [how to trig the window resize event in JavaScript?](http://stackoverflow.com/questions/1818474/how-to-trig-the-window-resize-event-in-javascript) – Pekka Sep 04 '10 at 16:05
  • Not a duplicate; asker wants to listen for event, not trigger it – Chris Laplante Sep 04 '10 at 16:07
  • @SimpleCoder of course, you're right. Here's a better one: http://stackoverflow.com/questions/641857/javascript-window-resize-event – Pekka Sep 04 '10 at 16:09

1 Answers1

3

Yes: http://api.jquery.com/resize/

but the event fires crazily. Use this instead (second example down):

http://benalman.com/code/projects/jquery-dotimeout/examples/debouncing/

When resizing the window, the resize event will trigger at every interval, instead of triggering only when the resize event is finished. Use debouncing to ensure that it doesn't fire at every interval.

Chris Laplante
  • 29,338
  • 17
  • 103
  • 134