2016-10-30 59 views
0

我使视频的几个按钮与多个元素互动,但这些元素是全屏最好的节目,所以我正在寻找解决方案来整合代码(如果可能的话),以便当我点击我的视频时网站,视频将自动全屏显示。这可能吗?如何打开全屏视频?

<div style="position: relative; padding-bottom: 56.25%; "><iframe style="position: absolute; top: 0; left: 0;" frameborder="0" allowfullscreen scrolling="no" style="width: 1px; min-width: 100%; *width: 100%;" height="100%" src="https://playfilmstorage.blob.core.windows.net/media/published/398548bd-4bc9-42cf-ab5e-bd6a922afbf0/index.html?autoplay=false"></iframe></div> 
+1

全屏无法自动完成没有触发它的用户事件 – charlietfl

回答

0

试试这个:
有使用javascript的解决方案。它适用于Mozilla和Webkit浏览器。

您可以使用element.mozRequestFullScreen();element.webkitRequestFullScreen();

例子:

function goFullscreen(id) { 
    var element = document.getElementById(id); 

    if (element.mozRequestFullScreen) { 
     element.mozRequestFullScreen(); 
    } else if (element.webkitRequestFullScreen) { 
     element.webkitRequestFullScreen(); 
    } 
} 
<img class="video_player" src="image.jpg" id="player"></img> 
<button onclick="goFullscreen('player'); return false">Fullscreen</button> 

要允许全屏模式为元素,你需要设置你的iframe上allowFullScreen

<iframe src="iframe.html" width="100" height="100" allowFullScreen></iframe>