How to achieve full screen?

full screen

Element.requestFullscreen()
(1) This method makes an asynchronous request to display the element in full-screen mode.
(2) Request the browser (user agent) to set a specific element (even extending to its descendant elements) into full-screen mode, hiding all UI elements of the browser on the screen, and other applications. Returns a Promise that will become resolved when fullscreen mode is activated.
(3) There is no guarantee that an element will enter fullscreen mode. If permission to enter fullscreen mode is granted, the returned Promise will be resolved and the element will receive a fullscreenchange event to let it know that it is now in fullscreen mode. If the permission is denied, the promise will be rejected and the element will receive a fullscreenerror event. If the element has been detached from the original document, the document will receive these events.
(4) Support passing parameter FullscreenOptions.

navigationUI Controls whether to show the navigation UI when the element is in fullscreen mode. The default is "auto", which means the browser should decide what to do.
hide The browser's navigation interface will be hidden, and the entire size of the screen will be allocated to the display of the element.
show The browser will render the page navigation controls and possibly other user interface; the dimensions of the elements (and the perceived size of the screen) will be constrained to make room for this user interface.
auto The browser will choose which of the above settings apply. It's the default value.



Exit Full Screen

Document.exitFullscreen()
(1) It is used to request switching from full-screen mode to windowed mode, and a Promise will be returned, which will be set to the resolved state when the full-screen mode is completely closed.
(2) The user can exit the full-screen mode by pressing the ESC key (or F11).


event

fullscreenchangeCan be used to detect when fullscreen mode is turned on and off. The Document or Element to send a message to (listening) when fullscreen or exit fullscreen.

fullscreenerrorWhen the error occurs during switching between fullscreen and windowed modes. When an error occurs in full screen or exiting full screen, the error message is sent to the (monitored) Document or Element.



browser compatible

full screen

  • requestFullscreen
  • mozRequestFullScreen
  • webkitRequestFullscreen
  • msRequestFullscreen

Exit Full Screen

  • exitFullscreen
  • mozCancelFullScreen
  • webkitExitFullscreen
  • msExitFullscreen

Guess you like

Origin blog.csdn.net/Kate_sicheng/article/details/128199784