How to find out the browser is minimized in javascript
Hi I have a notification div(divNotify)
with some information and a timer on the homepage
Protected Sub Timer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Try
Me.GetNotification_Stats()
ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "Alert", "Show_NotifyDiv();", True)
Catch ex As Exception
Me.lblError.Visible = True
Me.lblError.InnerText = ex.Message
End Try
End Sub
divNotify
will be displayed for a certain period of time.
here i need when the user minimizes the browser he will be notified by the blinking browser and the browser color change.
but first of all how to know if browser is minified or not in javasript here i am using jquery for show div tag
function Show_NotifyDiv() {
$("#div_NotificationOuter").show(1000);
$("#div_NotificationOuter").animate({ bottom: '+=30px' }, 4000);
}
There is no way to figure out if the page is minified with JavaScript, but you can use the visibility API to determine if the page is visible to the user or not.
Currently available in Chrome, Mozilla and IE10.
- https://developer.mozilla.org/en/DOM/Using_the_Page_Visibility_API
- http://code.google.com/chrome/whitepapers/pagevisibility.html
- http://www.nczonline.net/blog/2011/08/09/introduction-to-the-page-visibility-api/
In addition to c69's answer, I would suggest the isVisible library . It has utility functions to access the W3C page visibility API and you don't need to worry about cross-browser support (unifies moz- or webkit-prefixed functionality)
maybe check the window size? I'm just guessing.
We'll be patient, but visibility: W3C defines visibility state