How to fix: Refused to display https://www.youtube.com/watch?v=xxx in a frame because it set X-Frame-Options to SAMEORIGIN.

Tadashi Shigeoka ·  Wed, August 3, 2016

When you specify a YouTube video page URL directly as the src for an iframe tag,

Refused to display ‘https://www.youtube.com/watch?v=xxx’ in a frame because it set ‘X-Frame-Options’ to ‘SAMEORIGIN’.

this error occurs.

YouTube

Refused to display 'https://www.youtube.com/watch?v=xxx' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

Incorrect iframe src


Using the embed URL format https://www.youtube.com/embed/xxx listed in YouTube’s [Share] - [Embed code] will prevent the error from occurring.

YouTube 埋め込みコード

Correct iframe src


That’s all from the Gemba.