jquery - javascript - Full screen -


if (!document.fullscreenelement     && !document.mozfullscreenelement     && !document.webkitfullscreenelement     && !document.msfullscreenelement) {       if (document.documentelement.requestfullscreen) {         document.documentelement.requestfullscreen();     } else if (document.documentelement.msrequestfullscreen) {         document.documentelement.msrequestfullscreen();     } else if (document.documentelement.mozrequestfullscreen) {         document.documentelement.mozrequestfullscreen();     } else if (document.documentelement.webkitrequestfullscreen) {         document.documentelement.webkitrequestfullscreen(element.allow_keyboard_input);     } } else {     if (document.exitfullscreen) {         document.exitfullscreen();     } else if (document.msexitfullscreen) {         document.msexitfullscreen();     } else if (document.mozcancelfullscreen) {         document.mozcancelfullscreen();     } else if (document.webkitexitfullscreen) {         document.webkitexitfullscreen();     } } 

i have code toggling full screen. works, has little issues.

  1. when i'm clicking full screen button, after refresh full screen mode exits, if press f11 , refresh, full screen won't exit.

  2. if full screen mode enabled, after pressing f11, clicking on full screen button, not work

how can fixed problems?

i don't know if you'll able fix issues. happen because there 2 different full screen modes:

  • one applied elements/documents trigger using javascript (the 1 using api). fullscreen lost when page reloads or when browse different page.
  • another native browser set user f11 (applied browser itself, , not page/document: if reload or browse different site, browser continue in fullscreen mode).

while can control first 1 js, cannot control other. makes sense usability/security point of view: should able control behavior within page, not outside of or user's preferences.

the issues facing happen because:

  • issue 1:
    • by default fullscreen flag unset. when go full screen mode api, setting flag, when refresh page, flag goes original value (unset) , full screen lost. same way other javascript variable reset when reloading page.
    • if set browser on fullscreen mode (using f11), remain way until exit fullscreen, independently of browse or if close browser. setting browser's preference.
  • issue 2:
    • actually, not issue works expected. problem going fullscreen (element) within fullscreen (window) (fullscreenception! :p). don't see apparent change, there change fullscreen flag set. can see difference in demo robert nyman. has added css page go red when on :fullscreen. press f11 , notice how background doesn't turn red, click "fullscreen/cancel fullscreen" buttons see how background color changes.

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -