1

I want to give iFrame 100% width and height according to its content but it is not taking 100% width nor 100% height.

I have tried to give by using position absolute but the iframe width increased more than the container where it lies.

Here is my code:

<iframe id="solar_panel" width="100%" height ="740"  src="<?php echo $s; ?>"></iframe>
<script>
var intervalListener = self.setInterval(function () {resizeIframe()}, 1000);
function resizeIframe() {
var obj =   document.getElementById('solar_panel');
var objH = obj.contentWindow.document.body.scrollHeight;
obj.style.height = obj.contentWindow.document.body.scrollHeight + "px";
 if (objH != 0) {
    window.clearInterval(intervalListener);
  }
}
jQuery(window).resize(function(){
    resizeIframe();
});
</script>

Please help me out of here.

Osmani
  • 300
  • 2
  • 16
  • 1
    possible duplicate of [Adjust width height of iframe to fit with content in it](http://stackoverflow.com/questions/819416/adjust-width-height-of-iframe-to-fit-with-content-in-it) – Chipowski Jul 15 '15 at 08:06
  • Your iframe need to be resize or you try a js solution to perform this ? Did you search a css solution ? – Antoine Pointeau Jul 15 '15 at 08:32

0 Answers0