Floating Youtube iframe embed
I've seen jQuery scripts calculate the hight of 100%/resizable width youtube embeds of the 开发者_开发技巧old style (object/embed).
Anyone know how to solve it with the new iframe embeds?
<iframe
title="YouTube video player"
class="youtube-player"
type="text/html"
width="640"
height="390"
src="http://www.youtube.com/embed/-p3atsZRPLc?rel=0"
frameborder="0"
allowFullScreen
></iframe>
Ended up using the old style embed and this script:
<script type="text/javascript">
//<![CDATA[
var $origVideo = $(".youtube, .youtube embed");
var aspectRatio = $origVideo.attr("height") / $origVideo.attr("width");
$(window).resize(function() {
var wrapWidth = $("#video").width();
$origVideo
.width(wrapWidth)
.height(wrapWidth * aspectRatio);
}).trigger("resize");
//]]>
</script>
精彩评论