Is it possible to detect if a screen is off through a browser? [closed]

With any method not requiring special permissions. I want to find out if a website can tell if my screen is off.

Can a browser access that information in any way?


The javascript method window.requestAnimationFrame can be used to request a callback before the window (or tab) is next refreshed. This may (in some circumstances) occur less frequently if the browser is able to determine that the window is not visible (the usual suggestion is if it is minimized or if another tab in the same window has the focus), and a script could detect that reduction in frequency. I haven’t tested it, but it seems plausible that at least some browsers might also detect the situation where the screen is off (or at least in power-saving mode, which is much easier to determine using standard APIs) and slow down the calls in that case.

Of course, this does not provide conclusive evidence that the screen is off — the slow down could have occurred for many reasons — but it could provide a potential hint.

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *