Website censorship on lost focus

Tim Wells
4 min readJun 29, 2021

Let’s do a gimmicky little bit of JavaScript that will censor a website if the focus is lost. For this what we will make happen is to cover the screen in black if it loses focus. Losing focus could happen when another app is opened, causing the web browser to be in the background or simply when switching to another browser tab.

Photo by Shahadat Rahman on Unsplash

For this example we are going to cover the page from view, but you could use…

--

--

Tim Wells

Self taught software developer and photographer.