Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is a great tip. To make it compatible with most modern browsers (Chrome, Firefox, Opera, Safari and MS), you'll need to use the following checks:

        if (typeof window.document.hidden !== 'undefined') {
            hidden = 'hidden';
        }
        else if (typeof window.document.msHidden !== 'undefined') {
            hidden = 'msHidden';
        }
        else if (typeof window.document.webkitHidden !== 'undefined') {
            hidden = 'webkitHidden';
        }

        doVisualUpdates = !window.document[hidden];

reference: https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibi...


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: