$(document).ready(function(){ var ifr = $("#04G40664114H72Z0"); 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();});