AurelioDeRosa / HTML5-API-demos

A repository where you can find information about many JavaScript and HTML5 APIs.
706 stars 179 forks source link

Doubt regarding page visibillity api #6

Closed sktguha closed 9 years ago

sktguha commented 9 years ago

Hi, Isn't the function of page visibillity similiar to window.onblur. The only difference I could see was that for onblur to trigger the page needs to be clicked and then it's focus must be lost but in page visibillity the page simply needs to come out of view without being active. are there any other differences ? Thanks Saikat

AurelioDeRosa commented 9 years ago

This question doesn't belong to this repository because it isn't an issue regarding the demos, so I'm closing it.

However, to reply to your question, consider that what you mentioned is an important difference. Besides, the API has 4 states (hidden, visible, prerender, unloaded) that you don't have with the blur/focus mechanism. In the specifications page there is also a note that might interest you:

The Page Visibility API enables third party content on a web page to determine the visibility of the Document contained by the top level browsing context with higher precision compared to existing mechanisms, like focus or blur events. However, for practical considerations, the additional exposure is not substantial.

sktguha commented 9 years ago

Thank you for responding :) . I was just looking for a way to contact you and couldn't find other way how to ask this.