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.
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.
Share Improve this question asked Feb 16, 2009 at 3:03 JoeJoe 1- any luck to find answer on your question? – st78 Commented Apr 20, 2010 at 14:20
3 Answers
Reset to default 3Minimizing 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)
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./view/6284/jquery--window-on-resize-event/
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.