Automatic adjustion of iFrames according to content size

When iFrames have scrollbars, it really doesn't look good and user experience is spoiled too. So, it would have been better if iFrames adjusted themselves according to the content they have in them. JavaScript has the solution.


<script language="javascript" type="text/javascript">
  function resize(obj) {
    obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
  }
</script>

Now, the iFrame,

<iframe src="http://www.mp3jack.in/" frameborder="0" scrolling="no" id="iframe" onload='javascript:resize(this);' />

That's all.
Emoticon? Emoticon

Komentar Terbaru

Just load it!