-1

I was able to load internal pages with full width successfully using this

<script type="text/javascript">
     function calcHeight()
     {
     //find the height of the internal page
     var the_height=
     document.getElementById('the_iframe').contentWindow.
     document.body.scrollHeight;

     //change the height of the iframe
     document.getElementById('the_iframe').height=
     the_height;
     }
</script>

<iframe width="100%" src="/mypage.php" 
scrolling="no" id="the_iframe" onLoad="calcHeight();" height="1px" frameborder="0" ></iframe>

This is working great for any INTERNAL pages (page from same domain). I am struggling to get it work with external pages (cross-domain) but didnt find any solution.

IT SEEMS IT IS IMPOSSIBLE TO DO CROSS DOMAIN COMMUNICATION WHICH I REALLY DIDN'T EXPECT. WHATEVER, THANK YOU ALL.

Kalid
  • 157
  • 1
  • 1
  • 10
  • I know contentWindow.document is responsible for calling internal pages. But what should i use for calling external? – Kalid Jan 15 '15 at 07:03
  • You can't. See: [Getting iframe content's height while iframe is hosting an EXTERNAL website whose code CAN'T be accessed](http://stackoverflow.com/questions/9504447/getting-iframe-contents-height-while-iframe-is-hosting-an-external-website-whos) –  Jan 15 '15 at 07:04
  • You can't "load" cross-domain pages on your domain. Read about XSS. – Emanuel Vintilă Jan 15 '15 at 07:04
  • @ whatever it is, it just didnt work – Kalid Jan 15 '15 at 07:04

1 Answers1

1

It is impossible to access the contents of iframes that are referencing cross domain urls.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928