Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve "Allow attribute will take precedence over allowfullscreen" warning?

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');
like image 907
Andrew Rasmussen Avatar asked Aug 26 '19 22:08

Andrew Rasmussen


1 Answers

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', '');
like image 126
Andrew Rasmussen Avatar answered Sep 18 '22 15:09

Andrew Rasmussen