2015-11-04 51 views
1

嘗試嵌入視頻後,網站將不會顯示它。Bootstrap響應式Youtube嵌入不允許跨越原始幀

用下面簡單的HTML代碼:

<div class="embed-responsive embed-responsive-16by9"> 
     <iframe class="embed-responsive-item" src="https://www.youtube.com/watch?v=n01ogXL-q9I"></iframe> 
    </div> 

我提出與控制檯錯誤:

Load denied by X-Frame-Options: https://www.youtube.com/watch?v=n01ogXL-q9I does not permit cross-origin framing.

有一個簡單的安全補丁?我相信這與一些安全有關,以防止點擊劫持攻擊?如果Youtube嵌入對用戶可見,我更喜歡它。

回答

2

視頻不被顯示的簡單原因是視頻在使用之前需要在任何其他網站中嵌入。

您的代碼:

<div class="embed-responsive embed-responsive-16by9"> 
    <iframe class="embed-responsive-item" src="https://www.youtube.com/watch?v=n01ogXL-q9I"></iframe> 

您需要www.youtube.com/embed/總是更換/watch?v=如下圖所示:

<div class="embed-responsive embed-responsive-16by9"> 
    <iframe class="embed-responsive-item" src="https://www.youtube.com/embed/n01ogXL-q9I"></iframe> 
</div>