2

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.

asked Feb 16, 2009 at 3:03
1
  • any luck to find answer on your question? Commented Apr 20, 2010 at 14:20

3 Answers 3

3

Minimizing the window (or switching to another application) should fire the window.onblur event. Activating the window should fire window.onfocus

Implementation details may differ slightly between browsers but there seems to be no better way in default javascript (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)

Jared Forsyth
13.3k7 gold badges49 silver badges56 bronze badges
answered Feb 16, 2009 at 3:42
Sign up to request clarification or add additional context in comments.

Comments

1

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/

answered Feb 16, 2009 at 3:31

Comments

0

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

You could try detecting a resize or blur event on the window, however those can be triggered by things other than a minimize.

answered Feb 16, 2009 at 3:32

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.