Anatomy of a giant
jQuery(document).ready(function($) { //$(".jq1").html("jquery test passed"); // Find all iframes var $iframes = $( "iframe" ); // Find and save the aspect ratio for all iframes $iframes.each(function () { $( this ).data( "ratio", this.height / this.width ) // Remove the hardcoded width and height attributes .removeAttr( "width" ) .removeAttr( "height" ); }); // Resize the iframes when the window is resized $( window ).resize( function () { $iframes.each( function() { // Get the parent container's width var width = $( this ).parent().width(); var ratioCalc = $( this ).data( "ratio" ); if (width>550) { ratioCalc = 1000/500; } $( this ).width( width ) .height( width * ratioCalc ); }); // Resize to fix all iframes on page load. }).resize(); });