Online tab focus detector — what a page records when you switch away
Checking…
Reading what this document reports about its own visibility and focus.
This page runs, in your own browser, the same focus and visibility check an online assessment or proctoring page runs. Switch tabs, click another window, or minimise this one, and watch precisely what gets recorded. Nothing is uploaded — every reading below stays in this tab.
Event log
Switch tabs, click another window, or minimise this one — then come back.
Signals
| # | Time | Event | Reported state | Away for |
|---|---|---|---|---|
| Nothing yet. Switch to another tab or click another window, then come back. | ||||
What this test reads
Every browser exposes two independent readings. document.visibilityState says whether this tab is the one being shown, and document.hasFocus() says whether this document is the one receiving keystrokes. Neither needs a permission, and neither can be turned off.
They are not the same reading. Switching to another tab makes the page hidden. Clicking a second browser window, a chat app or a terminal leaves this tab visible but takes focus away — the page is blurred, not hidden.
Assessment platforms usually log both, count them separately, and time how long each absence lasted. The table below shows exactly the record they would build.
What sets it off
- Switching to another tab — fires
visibilitychange, state becomes hidden. Logged everywhere, including on phones. - Minimising the window, or locking the screen, or the phone going to sleep — also hidden.
- Clicking another window or app — a second browser window, an editor, a messaging app, a spotlight or launcher panel. The tab stays visible; the window
blurevent fires instead. - Opening developer tools in a separate window — counts as a window switch, so it fires blur.
- A tab being discarded or frozen by the browser to save memory — fires
freezeandpagehideon Chromium. - Closing or reloading the page — fires
pagehide, which is the event platforms use to close out an unfinished attempt.
Before an online assessment
If a test warns you that leaving the page is recorded, it is worth knowing what that actually means before you sit it.
- Open this page in the browser you will actually use for the assessment, and leave it open.
- Switch to another tab and come straight back. Note that the log records a hidden event and the exact number of seconds.
- Now click a different window instead — a chat app or an editor. The log shows a blur event, and the tab was never hidden.
- Turn on the lockout overlay to see what an assessment page shows the moment you leave. Many platforms display exactly this.
- Watch out for the accidental ones: a notification banner, a password manager pop-up in its own window, or an external keyboard-shortcut launcher will all register.
Knowing what is recorded is not the same as beating it. This page tells you what the reading is; how a platform interprets it is up to them.
How the verdict is reached
Focused — visibilityState is visible and hasFocus() is true. This tab is on screen and receiving your keystrokes.
Blurred — still visible, but focus has gone elsewhere. You are looking at this tab while typing into something else, or another window sits on top.
Hidden — the tab is not being rendered at all: another tab is in front, the window is minimised, or the device screen is off.
The away timer starts on the first event that takes focus and stops when both readings return to true, so a blur that turns into a tab switch is counted as one continuous absence.
What it cannot see
None of these readings say where you went. A page learns that this tab stopped being the active one and for how long — not which tab, which app, or what was on screen.
Anything that happens outside the browser without moving the keyboard focus is invisible to this API, because there is no event to fire. That includes a second physical device, a printed page, or another person in the room.
The count is not proof of anything on its own. A notification stealing focus, a screen-reader panel, an operating-system update prompt and a genuine tab switch produce the same event.
Serious proctoring does not rely on this alone. Camera, microphone, screen-share and installed lockdown browsers see far more than a web page can — see the external monitor detection test for another reading a page can take without asking.
Privacy
The page is static. It has no analytics, no cookies, no local storage, and makes no network requests at all after it loads.
Every counter and timestamp on this page is computed inside your tab and is gone the moment you close it. Reloading resets everything.
You can read the whole thing: it is a single file of JavaScript, linked from the footer.
Browser support
visibilitychange and document.hasFocus() work in every current browser, desktop and mobile, with no permission and no secure-origin requirement.
freeze and resume are Chromium-only, and fire when the browser suspends a background tab to save memory. Other browsers simply never report them.
On iOS, switching apps reports hidden rather than blurred, because the whole browser is backgrounded. The distinction between the two only exists where windows do.
Frequently asked questions
Can a website detect when I switch tabs?
Yes, and it needs no permission. The visibilitychange event fires the instant your tab stops being the visible one, and document.visibilityState reports hidden until you return. Every current browser implements it, including mobile ones. There is no setting that hides this from a page.
Can an online assessment tell the difference between switching tabs and opening another app?
Yes. Switching tabs makes the page hidden; clicking another window or application leaves the page visible but removes keyboard focus, which fires a blur event instead. A platform that logs both can tell those two apart, and this page shows each one separately so you can see the difference yourself.
Does an online test know which tab or app I switched to?
No. The browser tells the page only that it is no longer the active document, and how long that lasted. The destination — another tab, another program, a locked screen — is never exposed. Anything more detailed requires screen sharing or an installed lockdown browser, both of which are visible and have to be approved.
Does taking a screenshot count as leaving the page?
It depends entirely on how the screenshot is taken. A shortcut handled by the operating system with no interface of its own fires nothing, because the browser never loses focus. Anything that opens a picker, a panel or a preview window does take focus, and that registers as a blur. Try both on this page and watch the log.
Why did my tab switch counter go up when I did not switch tabs?
Focus is stolen by more things than people expect: notification banners, password-manager pop-ups, an operating-system update prompt, a keyboard-shortcut launcher, or developer tools opened in their own window. All of them fire a blur event that is indistinguishable from a deliberate switch.
Can this detection be turned off in browser settings?
No. The Page Visibility API is part of the document itself, not a permission, so there is nothing to revoke. Blocking it would break legitimate uses such as pausing video, stopping animation and halting timers in background tabs.
Does a second monitor stop tab switching from being recorded?
No. Moving your eyes to a second screen changes nothing, but clicking a window on that screen removes keyboard focus from this one and fires a blur event exactly as it would on a single display. Whether the second screen itself is visible to a page is a separate question, covered by the external monitor detection test.
Is any of this sent to a server?
No. The page is static, has no analytics and no cookies, and makes no network requests after it loads. Every event and timer shown is computed inside your tab and discarded when you close it.