jQuery(document).ready( function($){ resize_thickbox_iframe(); /* * * some other jQuery code * */ function resize_thickbox_iframe(){ //padding var pad = 50; // give the body a height $( 'body' ).css( 'height', 'auto' ); // read the bodys height and add some padding var mh = parseInt( $( 'body' ).height() ) + pad; var max_height = mh + 'px'; // get the parent window dimensions var parent = $( window.parent.document ); var ph = parent.height(); // get the ID of this iframe and the iframe itself frame_id = frameElement.id; frame = $( '#'+frame_id, window.parent.document ); // get the id of the overlay-div and the overlay-div itself div_id = frame.parent().attr( 'id' ); div = $( '#'+div_id, window.parent.document ); // first set the hight for the frame, than set the hight for the overlay-div frame.css( 'height', max_height ); div.css( 'height', max_height ); // calculate the new top position var tb = Math.round( ( ( ph - mh ) / 2 ) - pad ) + 'px'; // set the new top position frame.css( 'top', tb ); div.css( 'top', tb ); } } );