views:

2046

answers:

3

I have a div that toggles in and out of display when you click on another div. How could I modify my code so that when the user minimizes the whole browser window it automatically toggles, hiding the div from view so when the user un-minimizes window the div is no longer visible.

A: 

From a quick search it looks like you can attach an event to the windows resize event, then call the required toggle functions from there as usual. I havnt actually tested the linked sample though...

$(window).bind('resize', function() { ....

http://snipplr.com/view/6284/jquery--window-on-resize-event/

RM
A: 

In JavaScript, there is no way to detect when a window is minimized.

You can detect a resize, however that can be triggered by any number of actions. I don't think it will actually be triggered from a minimize event though.

Dan Herbert
+2  A: 

If the window is minimized you can handle window.onfocus, this event will be fired. And window.onblur will be fired when the window will be minimized. In these handlers you should check whether window.outerHeight and window.outerWidth changed (works in firefox). This is a tricky way but there are no better (may be you can use some flash object if flash can detect minimizing/maximizing of the window to fire necessary events, but I'm not familiar with flash)

zihotki