gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 02:06:54 25 4
gpt4 key购买 nike

我是 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.

关于防止屏幕保护程序启动的javascript代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4504238/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com