0 Members and 1 Guest are viewing this topic.

Iframe resizing
« on: August 17, 2015, 07:33:48 AM »
The main problem with using iframe is you have to use a fixed height and width. Fixed width is fine but many of the things you use iframes for need a varible height. This tip lets you use iframes and will auto resize the height to fit your content.

In you index_header.tpl file ad this just before the </head> tag
Code: [Select]
<script language="javascript" type="text/javascript">
  function resizeIframe(obj) {ldelim}
    obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
  {rdelim}
</script>

The iframe code below is a same just change the width to the % or px you want and the link to the php file or external link.
Code: [Select]
<iframe src="http://{$docroot}/yourphpfile.php" width="100%" frameborder="0" scrolling="no" onload='javascript:resizeIframe(this);' /></iframe>