Resizing iframe from content

When you want to give both your advertisers and your users the best experience, you sometimes want to resize an iframe (and maybe also a surrounding div) from within the iframe’s content.

For instance – if you’ve booked a 728×90 in a 930×180 container, you might want to collapse the ad space to half of the original height.

The solution is simple – add this to your ad code

<script language="javascript">
if (window.frameElement) window.frameElement.style.height = "90px";
// if you also have a surrounding div:
if (window.frameElement.parentElement) window.frameElement.parentElement.style.height = "90px";
</script>

Leave a Reply

Your email address will not be published.