问题
I have the following method which works on the 1st call, however if I hit the Esc key and then try my FullScreen button nothing happens. Debugging the code shows the else is not executing so document.body.requestFullScreen() is being called again but it has no effect??
What did I miss?
/**
* Full Screen Mode
+ works on Windows7 Chrome v80 and Android Chrome.
- 20180415
- 20200417 Moved from ChannelsTitleComp
*/
FullScreenToggle() {
// document.body.requestFullscreen() works on Windows Chrome and Android Chrome.
// https://stackoverflow.com/questions/53048372/how-to-programmatically-switch-display-from-standalone-to-fullscreen-in-pwa
if (document.body.requestFullscreen) {
document.body.requestFullscreen()
}
else {
Log.Write(this, "requestFullscreen", document.body.requestFullscreen)
document.exitFullscreen()
}
did not incorporate something like this for a toggle YET
// https://developers.google.com/web/fundamentals/native-hardware/fullscreen/
if (document.fullscreenElement)
document.exitFullscreen()
Thank you for your insights.
20200418 16:42 Update
A reply from Oscar requested to print the value of requestFullscreen the second time thru. I did and t seems to be the same according to the following console output.
Here is the code I used
来源:https://stackoverflow.com/questions/61283183/why-does-document-body-requestfullscreen-work-on-the-first-invocation-only