最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - requestFullscreen is not returning a promise - Stack Overflow

programmeradmin3浏览0评论

I'm facing an unexpected behavior and wanted to be sure i'm not missing something before i'm filling a bug.
I've played with requestFullscreen on chrome and firefox and noticed it's not returning a promise like stated in the spec.

Example for webkit:

el.addEventListener('click', () => {
    const p = el.webkitRequestFullScreen();
    p.then(() => {console.log('full screen')});
});

I'm getting:

Uncaught TypeError: Cannot read property 'then' of undefined at HTMLDivElement.el.addEventListener

Same goes for firefox:

el.addEventListener('click', () => {
    const p = el.mozRequestFullScreen();
    p.then(() => {console.log('full screen')});
});

TypeError: p is undefined

Am i reading the spec wrong? shouldn't i expect that promise?

I'm facing an unexpected behavior and wanted to be sure i'm not missing something before i'm filling a bug.
I've played with requestFullscreen on chrome and firefox and noticed it's not returning a promise like stated in the spec.

Example for webkit:

el.addEventListener('click', () => {
    const p = el.webkitRequestFullScreen();
    p.then(() => {console.log('full screen')});
});

I'm getting:

Uncaught TypeError: Cannot read property 'then' of undefined at HTMLDivElement.el.addEventListener

Same goes for firefox:

el.addEventListener('click', () => {
    const p = el.mozRequestFullScreen();
    p.then(() => {console.log('full screen')});
});

TypeError: p is undefined

Am i reading the spec wrong? shouldn't i expect that promise?

Share Improve this question edited Aug 28, 2018 at 6:50 Sagiv b.g asked Aug 28, 2018 at 6:37 Sagiv b.gSagiv b.g 31k10 gold badges72 silver badges104 bronze badges 2
  • 1 Ah... the [moz|webkit|o|ms]Full[s|S]creen API... That's just a mess. You shouldn't expect anything than nightmares trying to make a cross-browser code... But yes, according to specs that's what should be returned. But since nobody follows the specs there, we don't have it. FF has a 3 yo bug-report about it, currently P5... For their defense, they keep the prefixed version exactly because they don't follow the specs. On the other hand I couldn't find Chrome's discussion about it, and they did map to unprefixed method... – Kaiido Commented Aug 28, 2018 at 7:03
  • @Kaiido thanks, been looking for that bug but had no luck finding it. – Sagiv b.g Commented Aug 28, 2018 at 7:07
Add a ment  | 

1 Answer 1

Reset to default 2

https://developer.mozilla/en-US/docs/Web/API/Element/requestFullScreen#Browser_patibility

Unfortunately there's no browser support for the promise-returning version.

发布评论

评论列表(0)

  1. 暂无评论