Refused to display https://www.youtube.com/watch?v=xxx in a frame because it set X-Frame-Options to SAMEORIGIN. の解決方法
- 2016 8/3
- カテゴリー : WebService
- youtube
- コメントを書く
YouTube の動画ページの URL をそのまま iframe タグの src に指定すると、
Refused to display ‘https://www.youtube.com/watch?v=xxx’ in a frame because it set ‘X-Frame-Options’ to ‘SAMEORIGIN’.
というエラーが発生してしまいます。
間違った iframe src
<iframe src="https://www.youtube.com/watch?v=xxx"></iframe> |
YouTube の [共有] – [埋め込みコード] に記載されている https://www.youtube.com/embed/xxx という形式の埋め込み用 URL を使えばエラーが発生しなくなります。
正しい iframe src
<iframe src="https://www.youtube.com/embed/xxx"></iframe> |
以上、現場からお送りしました。