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

javascript - How to resolve "Allow attribute will take precedence over allowfullscreen" warning? - Stack Overf

programmeradmin0浏览0评论

Allow attribute will take precedence over 'allowfullscreen'.

I'm getting this warning message because I've added an iframe with both allow="fullscreen" and allowfullscreen.

allow doesn't seem to work in IE, Edge, or Firefox, according to .

How can I resolve/silence this warning message in a cross-browser compatible way?

Here's a minimal snippet to reproduce the warning message in Chrome:

const iframe = document.createElement('iframe');
iframe.setAttribute('allowFullScreen', '');
iframe.setAttribute('allow', 'fullscreen');

Allow attribute will take precedence over 'allowfullscreen'.

I'm getting this warning message because I've added an iframe with both allow="fullscreen" and allowfullscreen.

allow doesn't seem to work in IE, Edge, or Firefox, according to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe.

How can I resolve/silence this warning message in a cross-browser compatible way?

Here's a minimal snippet to reproduce the warning message in Chrome:

const iframe = document.createElement('iframe');
iframe.setAttribute('allowFullScreen', '');
iframe.setAttribute('allow', 'fullscreen');
Share Improve this question edited Aug 26, 2019 at 22:33 Andrew Rasmussen asked Aug 26, 2019 at 22:08 Andrew RasmussenAndrew Rasmussen 15.1k10 gold badges46 silver badges84 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 9

Turns out swapping the order of those setAttribute lines silences the warning:

const iframe = document.createElement('iframe');
iframe.setAttribute('allow', 'fullscreen'); // must be 1st
iframe.setAttribute('allowFullScreen', '');

On a Vimeo embed iFrame, remove allowFullScreen altogether.

From

<div class="embed-responsive embed-responsive-16by9"><iframe src="https://player.vimeo.com/video/000000000" allow="autoplay; fullscreen" allowfullscreen></iframe></div>

To

<div class="embed-responsive embed-responsive-16by9"><iframe src="https://player.vimeo.com/video/000000000" allow="autoplay; fullscreen"></iframe></div>

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论