Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the page visibility API actually support OS screen lock?

According to W3 Page Visibility specification and Mozilla's Page Visibility API documentation, the Page Visibility API supports detecting if a browser window is hidden because of the OS lock screen. Unfortunately, all of the examples I have found seem to indicate that this is not supported. I cannot get any example JS code or any of my JS code to report that the browser was hidden when I lock my screen (on Windows or OS X).
Some of the examples I have tried:

  • http://ie.microsoft.com/testdrive/Performance/PageVisibility/Default.html
  • https://jsfiddle.net/wvupJ/
  • https://jsfiddle.net/fakj0puw/1/

None of these report that the page was hidden when I lock my OS. Is this just not supported even though the documentation indicates otherwise?

Because I have to insert some code to be able to link to JSFiddle...

var results = document.getElementById('results');

function handleVisibilityChange() {
  if (document.webkitHidden) {
    results.innerHTML = results.innerHTML + 'Hidden.<br>';
  } else {
    results.innerHTML = results.innerHTML + 'Visible.<br>';
  }
}

document.addEventListener("webkitvisibilitychange", handleVisibilityChange, false);
like image 993
mittmemo Avatar asked Oct 23 '25 18:10

mittmemo


1 Answers

It works on OSX with Safari 8. (For lock and screen saver)

However no browser I found works for Windows.

As of 27/04/2015

like image 149
xbtsw Avatar answered Oct 26 '25 06:10

xbtsw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!