Embedding an HTTP / https video stream in Youtube format

I post a Youtube video on my website like this:

<iframe class="frame-for-top" width="300" height="200" src="https://www.youtube.com/embed/nb9GMm7QtlM" frameborder="0" allowfullscreen></iframe>

Now, when I open the console, I get an error message for all of my embedded YouTube videos that say:

: 1 Uncaught SecurityError: the frame with the source " https://www.youtube.com " was blocked from accessing the frame with the source code " http://mywebsite.com ". The request for access to the frame has the protocol "https", access to the frame has the protocol "http". protocols must comply.

I tried changing the "src" in the iframe to http , not https , but I don't know if it's ok to do this. Any feedback?

UPDATE:

still getting errors even in a JS script; enter image description here

+4
source share
2 answers

You need to add the source parameter to your src url, and then you can use the protocol httpin your iframe:

As an additional security measure, you should also specify the origin parameter in the URL, specifying the URL scheme (http: // or https: //) and the full domain of your main page as the parameter value. While the source is optional, it also protects against malicious third-party JavaScript that enters your page and takes control of your YouTube player.

Example:

<iframe id="player" type="text/html" width="640" height="390"
  src="http://www.youtube.com/watch?v=nb9GMm7QtlM?origin=http://mywebsite.com"
  frameborder="0"></iframe>
+3
source

You should use:

src="https://www.youtube.com/embed/videoID"

It worked for me.

0
source

Source: https://habr.com/ru/post/1598131/


All Articles