编程语言
首页 > 编程语言> > javascript代码,以防止屏幕保护程序启动

javascript代码,以防止屏幕保护程序启动

作者:互联网

我是javascript编程的新手,我有一个问题,我无法在任何地方找到答案.

我最近整理了一个简单的幻灯片,以远程查看我在家用计算机上托管的照片.这本身就可以.我遇到的问题是,当我查看照片时,我不会与硬件交互,这会在一段时间后导致显示器关闭.在我的手机上观看照片时,这尤其令人讨厌.

我的问题是:有没有办法防止这种情况发生?每次刷新照片时,我都在考虑伪造鼠标或其他事件的方向,但我不知道如何做到这一点,如果有可能的话.

任何帮助是极大的赞赏!

解决方法:

不可以.浏览器上的JavaScript无法与底层系统交互.在浏览器中模拟击键不会阻止屏幕保护程序打开.这是出于安全原因,因此恶意代码在您访问网页时不会损害系统.

Link on JavaScript Security

The modern JavaScript security model
is based upon Java. In theory,
downloaded scripts are run by default
in a restricted “sandbox” environment
that isolates them from the rest of
the operating system. Scripts are
permitted access only to data in the
current document or closely related
documents (generally those from the
same site as the current document). No
access is granted to the local file
system, the memory space of other
running programs, or the operating
system’s networking layer. Containment
of this kind is designed to prevent
malfunctioning or malicious scripts
from wreaking havoc in the user’s
environment. The reality of the
situation, however, is that often
scripts are not contained as neatly as
one would hope. There are numerous
ways that a script can exercise power
beyond what you might expect, both by
design and by accident.

标签:keep-alive,javascript,screensaver
来源: https://codeday.me/bug/20190929/1832453.html