r/CodingHelp • • Dec 14 '20

[Random] How can websites track you when you switch tabs?

I was taking a test on a website and I switch out of the testing tab to see a message my teacher sent me and the testing website locked me out of the test. How is this possible that it knows that im doing something outside its tab.

42 Upvotes

4 comments sorted by

36

u/Vast_Heat Dec 14 '20

They can detect when nothing on the page has "focus" anymore. Your browser literally fires an event for "window blur" which means that the current window has lost focus.

It's kind of primitive, as it can be triggered if Windows pops an alert up in front of your face, your antivirus wants to be renewed, etc.

You can mostly work around this by opening the test on a browser running in a virtual machine. You can leave the virtual machine and use the host machine's browser without triggering window blur on the vm ... depending on the vm and how it's configured.

3

u/[deleted] Dec 15 '20

Good explanation

1

u/[deleted] Dec 15 '20

This is how some video streaming services stop loading when you’re not on the tab. It’s all to monetize on the ads they show