Added cross-browser support for Page Visibility API