Here’s a simple Browser Tab Tracker using JavaScript that detects when the tab is active or inactive and logs status changes. You can expand this to add timestamps, session duration, or server communication.
Code: Browser Tab Tracker (Vanilla JS + HTML)
Features:
-
Detects when the tab becomes hidden or visible.
-
Displays current tab status (
active
orinactive
). -
Logs every status change with timestamp.
-
Runs purely in the browser without backend.
How to Use:
-
Copy and save the code as
tab-tracker.html
. -
Open it in any browser.
-
Switch tabs or minimize the window to see the status change and log updates.
Let me know if you’d like to add tracking analytics, store data in local storage, or connect to a backend API.
Leave a Reply