sindresorhus / screenfull

Simple wrapper for cross-browser usage of the JavaScript Fullscreen API
https://sindresorhus.com/screenfull
MIT License
7.06k stars 698 forks source link

Uncaught (in promise) TypeError: fullscreen error #219

Open nicky132 opened 1 year ago

nicky132 commented 1 year ago
image image

Hope someone solve this problem. I want to open page fullscreen automatically, when i jump to the new page with window.location.href.

brandonk1234 commented 1 year ago

Hi @nicky132 ,

Could you possibly try wrapping your function call in a conditions like this.

if (screenfull.isEnabled) {
    screenfull.toggle();
}

This seemed to fix my problem.

hbatalhaStch commented 1 year ago

Hi @nicky132 ,

Could you possibly try wrapping your function call in a conditions like this.

if (screenfull.isEnabled) {
    screenfull.toggle();
}

This seemed to fix my problem.

I tried this but I am still getting the error. The strange thing is that despite the error it still goes into fullscreen mode

clinton9ice commented 1 year ago

Could you try using if (screenfull.isEnabled) { screenfull?.toggle(); } It worked for me. it either executes when available or returns undefined.