使用 javascript 设置 IFrame allowfullscreen

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11034473/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 04:08:36  来源:igfitidea点击:

Set IFrame allowfullscreen with javascript

javascripthtmliframefullscreen

提问by Danny Fox

I tried to set allowfullscreen attribute to the iframe, but it doesn't work:

我试图为 iframe 设置 allowfullscreen 属性,但它不起作用:

iframe.allowFullScreen = true

I checked it with chrome -> inspect element, but the iframe has no allowfullscreen attribute, after this code.

我用 chrome -> inspect 元素检查了它,但是在这段代码之后,iframe 没有 allowfullscreen 属性。

Thanks in advance,

提前致谢,

回答by Aelios

iframe.setAttribute('allowFullScreen', '')

iframe.setAttribute('allowFullScreen', '')