$(document).ready(function(){ var ifr = $("#00A20050153S72M0"); ifr.data("ratio", ifr.attr("height")/ifr.attr("width") ); ifr.removeAttr("width").removeAttr("height"); // Resize the iframes when the window is resized $(window).resize(function(){ var width = ifr.parent().width(); ifr.width(width).height(width * ifr.data("ratio")); }).resize();});