Skip to main content

Advertisement

Advertisement

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(); });

Read more of the latest in

Advertisement

Advertisement

Stay in the know. Anytime. Anywhere.

Subscribe to get daily news updates, insights and must reads delivered straight to your inbox.

By clicking subscribe, I agree for my personal data to be used to send me TODAY newsletters, promotional offers and for research and analysis.