Resize iframe Using jQuery on SharePoint

JavaScript to resize an iframe on a SharePoint custom page.

<script type=”text/javascript”>
// id = jQuery id of the iframe to auto resize.
// lessHeight = the amount in pixels to subtract from the browser window height when resizing the iframe.
// minHeight = the minimum height of the iframe.
function ResizeIFrame(id, lessHeight, minHeight)
var newHeight = window.document.body.offsetHeight – lessHeight;
var iframeHeight = (newHeight < minHeight) ? minHeight : newHeight;

// Register an iframe to be auto resized.
function ResizeIFrameRegistration(id, lessHeight, minHeight)
// Resize the iframe with the browser window is resized.
$(window).resize(function() { ResizeIFrame(id, lessHeight, minHeight); });
// Resize the iframe when browser page is finished loading and ready.
$(document).ready(function() { ResizeIFrame(id, lessHeight, minHeight); });

ResizeIFrameRegistration(“#<%= pdf.ClientID %>”, 250, 300);