2016-10-30 63 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>