Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect if current window is behind another window, using Javascript

Tags:

javascript

dom

Is it possible to detect whether the web browser window is currently covered by another window?

document.hidden and document.visibilityState only changes state on switching tabs or when the entire window is minimized.

document.hasFocus() returns false if the window is visible but not in focus (e.g. the focus is on the taskbar)

like image 957
mocax Avatar asked Apr 10 '26 01:04

mocax


1 Answers

Nope, that's not possible.

There's no way in JavaScript to know how visible the window is.

like image 72
Cerbrus Avatar answered Apr 12 '26 13:04

Cerbrus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!