Last active
October 4, 2021 16:43
-
-
Save fhtino/963e36294a1490782dc6ab863b2802b6 to your computer and use it in GitHub Desktop.
wakelocktests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<div id="infoDiv">...<br /></div> | |
<script type="text/javascript"> | |
async function DoTest() { | |
var infoDiv = document.getElementById("infoDiv"); | |
let wakeLock = null; | |
if ('wakeLock' in navigator) { | |
infoDiv.innerHTML += "wakeLock supported<br/>"; | |
wakeLock = await navigator.wakeLock.request('screen'); | |
infoDiv.innerHTML += "Active!<br/>"; | |
wakeLock.addEventListener('release', () => { | |
// the wake lock has been released | |
infoDiv.innerHTML += 'Wake Lock has been released<br/>'; | |
}); | |
} else { | |
alert("NOT supported"); | |
} | |
} | |
DoTest(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment