Prevent display turn off in a Mobile Browser

前端 未结 2 1783
一向
一向 2021-01-02 10:12

I\'m creating a Mobile Based web page & I\'m using web socket connection to handle a chat room. But I want the display turning on every time when user go to the web page

相关标签:
2条回答
  • 2021-01-02 10:25

    There is a Working Draft for a new Wake Lock API, which doesn't seem to be implemented anywhere.

    For now, you can take a look at NoSleep.js:

    Prevent display sleep and enable wake lock in all Android and iOS web browsers.

    It requires user interaction though, meaning you have to attach it to a user input event handler (eg mouse/touch).

    0 讨论(0)
  • 2021-01-02 10:29

    Since most mobile OSs require user interaction to stop the screen from going to sleep this is impossible from a website. You'll need to make a native app.

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