2

I have an iframe and the content of it comes from cross domain. I do not have access to the crossdomain to add any javascript. I would like to increase the height of the iframe dynamically based on the content inside the iframe. I googled before posting here, but no concrete answer was found. I tried this

document.getElementById("sceIframe").contentWindow.document.body.scrollHeight

but, since its a crossdomain, I am getting permission denied.

Can anyone please throw some sample code on how to do this?

T. Junghans
  • 11,385
  • 7
  • 52
  • 75
CodeIssue
  • 21
  • 2
  • http://stackoverflow.com/questions/5606920/cross-domain-iframe-resizer – kol Oct 12 '13 at 00:33
  • Thanks kol. But, the link talks only when i have access to the hosting domain as well. These plugins need to be placed in both hosting server as well as current iframe renderer. Like i said, i dont have access to cross domain. Any other thoughts? – CodeIssue Oct 14 '13 at 17:59
  • You can not achieve that if you are not able to get _both_ involved parties to do their part. – CBroe Oct 15 '13 at 08:35

1 Answers1

0

The following other answer: Get value of input field inside an iframe

should be of use to you. Short version: To pull it off you have to have the iFrame sourced from your own site and use server PHP to grab the data from the other site and fill it into your 'local iFrame'. Then you can access all aspects of it up to and including its height.

Community
  • 1
  • 1
SoItBegins
  • 414
  • 1
  • 6
  • 22
  • Thank you SoltBegins. The solution talks about how to access existing elements inside iframe. But, i am looking to find the height of the contents of iframe, which is not currently a field on the page. Also, its a php solution. I am looking for something that is of javascript. Again, i dont have access to the cross domain to add any plugins or code. Any other thoughts? – CodeIssue Oct 14 '13 at 18:04
  • 1
    Without having your own server do the crossdomain (a PHP solution), I really don't think it's possible. By definition, the crossdomain restrictions exist to prevent exactly what you're asking [client javascript jumping domains]. – SoItBegins Oct 15 '13 at 08:30