Your page can receive events when it becomes visible / not visible. See: https://www.w3.org/TR/page-visibility/.
ACME Labs / Web APIs / Page Visibility