Liga
Liga

Reputation: 3439

How to check if the browser is in fullscreen mode?

I know about the new Fullscreen API but I can't find anywhere a way to check if the browser at this time is in fullscreen mode. I'm specifically interested about Chrome. Is it even possible?

I'm looking for something like this

window.addEventListener('load', function() {
    if (FULLSCREEN) {
        console.log('We are in full screen mode!')
    } else {
        console.log('Normal mode')
    }
})

Upvotes: 1

Views: 3857

Answers (3)

Anthony Smith
Anthony Smith

Reputation: 1

Why not use the simple method of pressing F11. In this way, you can see if Chrome is viewed in full-screen or normal mode. Maybe you can find some advice reding this article https://rocketfiles.com/articles/how-to-exit-full-screen-chrome. I have not used the API you request but will try. Maybe will write to you more information later that I can learn from my side.

Upvotes: -2

radulfr
radulfr

Reputation: 616

If the document is in fullscreen mode, document.fullscreenElement will return the element that triggered the mode. When not in fullscreen, it returns null. In some browsers you may need to use the prefixed version, document.webkitFullscreenElement.

MDN: fullscreenElement

Upvotes: 6

Saima Haji
Saima Haji

Reputation: 175

As per the Fullscreen API mdn doc : https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API Its not supported in chrome.

Upvotes: 0

Related Questions