Removing annotations on embedded YouTube videos

I found that you can turn off annotations of embedded YouTube videos by adding the &iv_load_policy=3 parameter to the url in the embed code.

Example:

 <object width="425" height="344"> <param name="movie" value="http://www.youtube.com/v/PMnEvKCtHBw&hl=en&fs=1&iv_load_policy=3"></param> <param name="allowFullScreen" value="true"></param> <param name="allowscriptaccess" value="always"></param> <embed src="http://www.youtube.com/v/PMnEvKCtHBw&hl=en&fs=1&iv_load_policy=3" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed> </object> 

Is there a way to force this setting on all YouTube URLs in a webpage using javascript / jQuery?

(An example like this example where you force wmode to be transparent to all flash objects)

+4
source share
3 answers

Try the following:

 $('object').each(function(){ var $param = $(this).children(':first-child'); var newUrl = $param.attr('value') + '&iv_load_policy=3'; $param.attr('value', newUrl); }); 

Finish quickly without testing ....

Tested and working

+4
source

iv_load_policy=3 is the path. However, there is a good built-in code generator to do this for you.

0
source

The new HTML5 player no longer uses this code for embedding, but I just adapted this code to work with an iframe that embeds and works on my site. (Works also with WordPress)

 $("iframe").each(function() { var src = $(this).attr("src") + '&iv_load_policy=3'; $(this).attr("src", src); }); 
0
source

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


All Articles