{"componentChunkName":"component---src-templates-post-js","path":"/blog/2020/03/10/fullscreen-api/","result":{"data":{"post":{"html":"<p>There are many situations where we’d like to see our web page in fullscreen mode. Be it games, online courses, video tutorials, or simply wanting more reading space while reading a book. What we usually do in these sort of scenarios is we manually set our browser’s tab/window in fullscreen mode (<kbd>F11</kbd>), but the result is not always what we expect, because some content is not designed to be viewed in fullscreen mode. Besides, what if we help our users to go fullscreen automatically instead, again it all comes to having a better user experience.</p>\n<!--more-->\n<h2 id=\"intro\" style=\"position:relative;\"><a href=\"#intro\" aria-label=\"intro permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Intro</h2>\n<p><a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Full Screen API</a> adds methods to the HTML <code class=\"language-text\">Element</code> to enable us to programmatically turn any content on a page to enter in fullscreen mode via JavaScript. <code class=\"language-text\">WebGL</code>, <code class=\"language-text\">canvas</code>, and <code class=\"language-text\">video</code> elements are the usual targets when it comes to going fullscreen. Online newspapers and magazines are other areas where this can be helpful.</p>\n<p>So let’s see this in action first and then go through some details:</p>\n<iframe height=\"265\" style=\"width: 100%;\" scrolling=\"no\" title=\"Full Screen API Demo\" src=\"https://codepen.io/yashints/embed/preview/mdJpqYx?height=265&theme-id=light&default-tab=js,result\" frameborder=\"no\" allowtransparency=\"true\" allowfullscreen=\"true\">\r\n  See the Pen <a href='https://codepen.io/yashints/pen/mdJpqYx'>Full Screen API Demo</a> by Yaser Adel Mehraban\r\n  (<a href='https://codepen.io/yashints'>@yashints</a>) on <a href='https://codepen.io'>CodePen</a>.\r\n</iframe>\n<p>All we’re doing here is to call a method which is added by the Full Screen API:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"25937476332380860000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`const vid = document.getElementById('shuttle');\r\n\r\nfunction toggleFullScreen() {\r\n  if (!document.fullscreenElement && vid.requestFullscreen) {\r\n    vid.requestFullscreen();\r\n  } else {\r\n    if (document.exitFullscreen) {\r\n      document.exitFullscreen(); \r\n    }\r\n  }\r\n}\r\n\r\ndocument.addEventListener(&quot;keydown&quot;, function(e) {\r\n  if (e.keyCode == 13) {\r\n    toggleFullScreen();\r\n  }\r\n}, false);`, `25937476332380860000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">const</span> vid <span class=\"token operator\">=</span> document<span class=\"token punctuation\">.</span><span class=\"token function\">getElementById</span><span class=\"token punctuation\">(</span><span class=\"token string\">'shuttle'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token keyword\">function</span> <span class=\"token function\">toggleFullScreen</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span><span class=\"token operator\">!</span>document<span class=\"token punctuation\">.</span>fullscreenElement <span class=\"token operator\">&amp;&amp;</span> vid<span class=\"token punctuation\">.</span>requestFullscreen<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n    vid<span class=\"token punctuation\">.</span><span class=\"token function\">requestFullscreen</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n  <span class=\"token punctuation\">}</span> <span class=\"token keyword\">else</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>document<span class=\"token punctuation\">.</span>exitFullscreen<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n      document<span class=\"token punctuation\">.</span><span class=\"token function\">exitFullscreen</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> \r\n    <span class=\"token punctuation\">}</span>\r\n  <span class=\"token punctuation\">}</span>\r\n<span class=\"token punctuation\">}</span>\r\n\r\ndocument<span class=\"token punctuation\">.</span><span class=\"token function\">addEventListener</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"keydown\"</span><span class=\"token punctuation\">,</span> <span class=\"token keyword\">function</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">e</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>e<span class=\"token punctuation\">.</span>keyCode <span class=\"token operator\">==</span> <span class=\"token number\">13</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token function\">toggleFullScreen</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n  <span class=\"token punctuation\">}</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span> <span class=\"token boolean\">false</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"exposed-properties\" style=\"position:relative;\"><a href=\"#exposed-properties\" aria-label=\"exposed properties permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Exposed properties</h2>\n<p>There are two properties exposed on the <code class=\"language-text\">document</code> object:</p>\n<p>💡 <strong><code class=\"language-text\">DocumentOrShadowRoot.fullscreenElement</code></strong></p>\n<p>The <code class=\"language-text\">fullscreenElement</code> property will give you the element that is displayed in fullscreen mode at the moment. It’s a way to check whether we’re in full screen mode or not.</p>\n<p>💡 <strong><code class=\"language-text\">Document.fullscreenEnabled</code></strong></p>\n<p>The <code class=\"language-text\">fullscreenEnabled</code> property tells you whether or not the document is currently in a state that would allow fullscreen mode to be requested.</p>\n<h2 id=\"exiting-fullscreen\" style=\"position:relative;\"><a href=\"#exiting-fullscreen\" aria-label=\"exiting fullscreen permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Exiting fullscreen</h2>\n<p>You’ll want to be sure to let your users know that they can press the <kbd>Esc</kbd> key (or <kbd>F11</kbd>) to exit fullscreen mode.</p>\n<p>In addition, navigating to another page, changing tabs, or switching to another application (using, for example, <kbd>Alt</kbd>-<kbd>Tab</kbd>) while in fullscreen mode exits fullscreen mode as well.</p>\n<p>As you saw in the example above, exiting the fullscreen mode can be done using <code class=\"language-text\">document.exitFullscreen</code>:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"95378602583853860000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`if (document.exitFullscreen) {\r\n  document.exitFullscreen(); \r\n}`, `95378602583853860000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>document<span class=\"token punctuation\">.</span>exitFullscreen<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n  document<span class=\"token punctuation\">.</span><span class=\"token function\">exitFullscreen</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> \r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"feature-detection\" style=\"position:relative;\"><a href=\"#feature-detection\" aria-label=\"feature detection permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Feature detection</h2>\n<p>You can simply detect whether the feature is supported or not using either <code class=\"language-text\">document.requestFullscreen</code> or <code class=\"language-text\">Element.requestFullscreen</code>:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"70161223682537830000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`if(element.requestFullscreen) {\r\n  element.requestFullscreen();\r\n}`, `70161223682537830000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">if</span><span class=\"token punctuation\">(</span>element<span class=\"token punctuation\">.</span>requestFullscreen<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n  element<span class=\"token punctuation\">.</span><span class=\"token function\">requestFullscreen</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span></span></pre></div>\n<p>or:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"15794997655169874000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`if(document.requestFullscreen) {\r\n  // enter fullscreen mode\r\n}`, `15794997655169874000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">if</span><span class=\"token punctuation\">(</span>document<span class=\"token punctuation\">.</span>requestFullscreen<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token comment\">// enter fullscreen mode</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"finding-whether-or-not-youre-in-fullscreen-mode\" style=\"position:relative;\"><a href=\"#finding-whether-or-not-youre-in-fullscreen-mode\" aria-label=\"finding whether or not youre in fullscreen mode permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Finding whether or not you’re in fullscreen mode</h2>\n<p>As mentioned earlier, the <code class=\"language-text\">document.fullscreenElement</code> is a good way to check whether the browser is in full screen mode or not. The value of this property will be <code class=\"language-text\">null</code> if we’re not in fullscreen, and the current fullscreen element otherwise.</p>\n<div class=\"custom-block warning\"><div class=\"custom-block-body\"> ⚠️ There is also a <code class=\"language-text\">boolean</code> property called <code class=\"language-text\">fullscreen</code> which is deprecated and should not be used. Although most of the browsers still support it.</div></div>\n<h2 id=\"presentation\" style=\"position:relative;\"><a href=\"#presentation\" aria-label=\"presentation permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Presentation</h2>\n<p>When toggling fullscreen mode programmatically, you’re responsible for how the elements will look like and what appears on the screen. It’s obvious you will need to change the width and height of the element to <code class=\"language-text\">%100</code>, and fortunately, there is a CSS pseudo-selector for you to use:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"32875344895517400000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`#shuttle:fullscreen {\r\n  width: 100%;\r\n  height: 100%;\r\n}`, `32875344895517400000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"css\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-css line-numbers\"><code class=\"language-css\"><span class=\"token selector\">#shuttle:fullscreen</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token property\">width</span><span class=\"token punctuation\">:</span> 100%<span class=\"token punctuation\">;</span>\r\n  <span class=\"token property\">height</span><span class=\"token punctuation\">:</span> 100%<span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Also you might want to hide some other elements on the screen to reduce clutter:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"13822667260805433000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`:fullscreen .hide {\r\n  display: none;\r\n}`, `13822667260805433000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"css\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-css line-numbers\"><code class=\"language-css\"><span class=\"token selector\">:fullscreen .hide</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token property\">display</span><span class=\"token punctuation\">:</span> none<span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"browser-support\" style=\"position:relative;\"><a href=\"#browser-support\" aria-label=\"browser support permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Browser support</h2>\n<p>The browser support is really good at this point, almost all major browsers fully support it. Only <strong>IE11</strong> and <strong>Safari</strong> have partial support. Opera mini and Android Browser do not support it at this point.</p>\n<p><img src=\"/2f6bdf83bea61460d60ed9d65117439e/caniuse.png\" alt=\"Browser support for Full Screen API\"></p>\n<p>Hope you’ve learned a new trick if you didn’t know about this API and happy fullscreening (just made up the word 😁).</p>","timeToRead":2,"frontmatter":{"unformattedDate":"2020-03-10T00:00:00.000Z","date":"March 10, 2020","title":"What you need to know about Full screen API 💻","subtitle":null,"id":null,"author":"Yaser Adel Mehraban","gravatar":null,"canonical_url":null,"tags":["webdev","showdev","fullscreenapi","javascript"],"thumbnail":null,"cover":{"childImageSharp":{"gatsbyImageData":{"layout":"constrained","placeholder":{"fallback":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAIAAAA7N+mxAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB9UlEQVR42i3Oy46bMBgFYB67iz5Cl5U6iz7BLEaqqs5IHU2VNJlAwASapCEEzM3cb4YYAvYkaZ2q0qejo18+koW1X5v56VAMh6x3q1NQDwgPqB4CPHjVTdzSpB15cmlLo4YizC/UzVphlZBfqAEw28bHTdRYGbFibKftIW1gdrRTYoTYyQlMGv7aLwjMiRlhv+iiZhSWafekWw8/ls9g96zsprr1Iq9nuvVT2z8sNl9lYyKv52t7sjKm6m6u72eaMQHb1QGFDRPEsNHqtzU+GxVzm7PXnhG5huQSd9dNPq7zMT79QeSCuotHLgG5Rv2Vd9hedmkniFED0pPiYeBgPTjukt4qBrdmHmZJd07IxamZgzkKa2pX1MX0UFGjpNuEj2GhOlixauA2qn/ktIBsELGKEVbMLqlVMrNiJmZmzfb/C+V9cxvvM83FOqyA24qHYmHmC7NQvKPiEw74HQg6EPUgH9WKqQV7hVQJx13FNjERJIjlV1H//gXY1ZO0f5SMR9lUELltUAfCf4k6JSBadpqb7P278909/X2iS3QUgNd+exE/fbyT7GIJS9lvRKfkYxX1atjdoE6NejXutaRf2MOHz2/3s3Hb0oWDhfk25P+cGrlklyIHS8nDkpVJ+0QyU8ngmYlOJbo1J8ECoFIOahHWMyP9C8D8DfCSLBFhAAAAAElFTkSuQmCC"},"backgroundColor":"transparent","images":{"fallback":{"src":"/static/76ef623d922d7efe59cedc449cacb789/a2195/socialpreview.png","srcSet":"/static/76ef623d922d7efe59cedc449cacb789/cadb4/socialpreview.png 750w,\n/static/76ef623d922d7efe59cedc449cacb789/a2195/socialpreview.png 800w","sizes":"(min-width: 800px) 800px, 100vw"},"sources":[{"srcSet":"/static/76ef623d922d7efe59cedc449cacb789/11ba1/socialpreview.webp 750w,\n/static/76ef623d922d7efe59cedc449cacb789/5f042/socialpreview.webp 800w","type":"image/webp","sizes":"(min-width: 800px) 800px, 100vw"}]},"width":800,"height":400}}},"img":null,"socialPreview":{"publicURL":"/static/76ef623d922d7efe59cedc449cacb789/socialpreview.png"}}}},"pageContext":{"title":"What you need to know about Full screen API 💻","postPath":"/blog/2020/03/10/fullscreen-api","nextPost":"/blog/2020/03/19/debug-devtools","previousPost":"/blog/2020/02/28/mem-leak"}},"staticQueryHashes":[],"slicesMap":{}}