I have a page that has a height of 320px, with a div hidden with jQuery. When the div shows, the height is 450px. I have put this in an iFrame, and would like to resize the iFrame when the hidden div is shown. I found this code from this question -
jQuery(function($){
var lastHeight = 0, curHeight = 0, $frame = $('iframe:eq(0)');
setInterval(function(){
curHeight = $frame.contents().find('body').height();
if ( curHeight != lastHeight ) {
$frame.css('height', (lastHeight = curHeight) + 'px' );
}
},500);
});
And it works to increase the height of the frame, but I can't figure out how to get it to resize back to 320px when the div is hidden again. What would be the best way to modify this code so that the iFrame goes back to the original height of 320px?