javascript code to prevent screensaver from starting

后端 未结 5 410
小蘑菇
小蘑菇 2020-12-07 01:25

I am completely new to javascript programming and I have a question that I didn\'t manage to find an answer for anywhere.

I have recently put together a simple slide

相关标签:
5条回答
  • 2020-12-07 01:34

    No. JavaScript on the browser cannot interact with the underlying system. Simulating keystrokes in the browser will not stop the screen saver from turning on. This is for security reasons, so that malicious code can't harm the system when you visit a web page.

    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.

    0 讨论(0)
  • 2020-12-07 01:35

    Over the decade since this questions question was originally asked JavaScript has grown to provide much of the OS functionality (usually in a secure manner). The "wake lock" functionality is slowly being implemented. Currently there is a draft for the navigator.getWakeLock interface: https://www.w3.org/TR/wake-lock/#conformance

    Chrome (https://developers.google.com/web/updates/2018/12/wakelock) and Mozilla (https://developer.mozilla.org/en-US/docs/Archive/B2G_OS/API/Wake_Lock_API) are considering it in various manners.

    0 讨论(0)
  • 2020-12-07 01:37

    No, JavaScript cannot affect hardware or operating system. Just turn off monitor power saving settings until you're done with the slideshow.

    0 讨论(0)
  • 2020-12-07 01:50

    Yes, It's possible now :)

    Just use NoSleep.js library: https://github.com/richtr/NoSleep.js

    It's working form me with Reveal.js slides on my Android Tablet

    0 讨论(0)
  • 2020-12-07 01:53

    You could do it with a console application written in c# that interacted with the os

    since js is a client side browser language it can only interact with the browser/bowser

    0 讨论(0)
提交回复
热议问题