最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Jquery toggle on window minimize - Stack Overflow

programmeradmin3浏览0评论

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
Add a ment  | 

3 Answers 3

Reset to default 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)

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.

发布评论

评论列表(0)

  1. 暂无评论