问题
I've discovered that you can disable annotations on embedded YouTube videos by adding the parameter &iv_load_policy=3
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 any way to force this parameter on all YouTube embed urls on a webpage using javascript/jQuery?
(Sort of like this example where you force wmode transparent on all flash objects)
回答1:
Try this:
$('object').each(function(){
var $param = $(this).children(':first-child');
var newUrl = $param.attr('value') + '&iv_load_policy=3';
$param.attr('value', newUrl);
});
Done quickly without testing....
Tested and works
回答2:
iv_load_policy=3
is the way to go. However there are nice embed code generators, to do it for you.
回答3:
The new HTML5 player no longer uses this embed code, but I have just adapted this code to work with the iframe that is being embedded and have it working on my site. (Works with WordPress ombed too)
$("iframe").each(function() {
var src = $(this).attr("src") + '&iv_load_policy=3';
$(this).attr("src", src);
});
来源:https://stackoverflow.com/questions/8166846/removing-annotations-on-embedded-youtube-videos