Skip to main content

Advertisement

Advertisement

Results

#geframe1 { height:880px; } #geframe2 { height:880px; }

jQuery(document).ready(function($) { // Find all iframes var $iframes = $( "iframe" ); //var ratio1 = 0; //var ratio2 = 0; // Find and save the aspect ratio for all iframes $iframes.each(function () { if (this.id=="geframe1"){ $( this ).data( "ratio", this.height / this.width ) // Remove the hardcoded width and height attributes .removeAttr( "width" ) .removeAttr( "height" ); } if (this.id=="geframe2"){ $( 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() { if (this.id=="geframe1"){ // Get the parent container's width var width = $( this ).parent().width(); var ratioCalc = $( this ).data( "ratio" ); if (width<550) { // height/width ratioCalc = 2400/500; } $( this ).width( width ) .height( width * ratioCalc ); } if (this.id=="geframe2"){ // Get the parent container's width var width = $( this ).parent().width(); var ratioCalc = $( this ).data( "ratio" ); if (width<550) { // height/width ratioCalc = 2200/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.