Video not listed on youtube problems to open using iframe

Asked

Viewed 3,557 times

2

I am unable to open videos not listed on youtube using the html tag iframe, the following error occurs:

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

Does anyone know what it is? I tried using the video tag and it’s not working either.

   <iframe width="420" height="315"
                            src="videodoyoutubenaolistado"></iframe>
  • I solved the problem the very silly error, I entered the youtube link and using the embed button it generated me html code changing the url in the format that works.

1 answer

1

many famous sites end up blocking the embedding in iframes because it allows the creation of malicious sites, so whenever you think of using iframe for a site see if it itself does not offer option of embedding specific parts.

In the case of youtube to avoid errors like this because it does not allow the whole page and to have q avoid going catch the embed on the site you can change the url replacing watch? v= by embed/ this already causes you to get only the video window.

Example: https://www.youtube.com/watch?v=T-TwcmT6Rcw => https://www.youtube.com/embed/T-TwcmT6Rcw

you can see other functions here https://www.w3schools.com/HTML/html_youtube.asp

Browser other questions tagged

You are not signed in. Login or sign up in order to post.