admin管理员组文章数量:1281045
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 by mobile browser.
I tried to simulate Button Click from,
function eventFire(el, etype){
if (el.fireEvent) {
el.fireEvent('on' + etype);
} else {
var evObj = document.createEvent('Events');
evObj.initEvent(etype, true, false);
el.dispatchEvent(evObj);
}
}
But still mobile display turn off after particular time. Please can anyone help me with this??
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 by mobile browser.
I tried to simulate Button Click from,
function eventFire(el, etype){
if (el.fireEvent) {
el.fireEvent('on' + etype);
} else {
var evObj = document.createEvent('Events');
evObj.initEvent(etype, true, false);
el.dispatchEvent(evObj);
}
}
But still mobile display turn off after particular time. Please can anyone help me with this??
Share Improve this question asked Aug 29, 2014 at 19:55 DilumNDilumN 2,8976 gold badges32 silver badges44 bronze badges2 Answers
Reset to default 22There 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).
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.
本文标签: javascriptPrevent display turn off in a Mobile BrowserStack Overflow
版权声明:本文标题:javascript - Prevent display turn off in a Mobile Browser - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738430767a2086388.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论