By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,466 Members | 1,132 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,466 IT Pros & Developers. It's quick & easy.

Cross domain iframe dynamic height change issue.

P: 1
I am trying to display the content of a iframe in a div tag so that I can control the size of the display dynamically. The problem here is that the domain are different for parent window and the iframe content.

Code :
Expand|Select|Wrap|Line Numbers
  1. var x=document.getElementById('myIFrame');
  3. try{
  4.     x = x.contentWindow.document.body.innerHTML
  5. }catch (e){
  6. alert(e.message); 
  7. }
I am getting a "Access denied" exception. Is there a work around for the issue.

Please help.

[removed email]
Aug 20 '08 #1
Share this Question
Share on Google+
4 Replies

Expert Mod 15k+
P: 16,027
To get the content, the only workaround is to serve it from your own domain using a proxy.
Aug 20 '08 #2

P: 2


How exactly does this work?

I am hosting a web-site that is supposed to be shown in a great number of different sites, via an iframe. So the problem is really on the receiver's end: they would want to setup their iframe so that it receives our dynamic content with automatic height.

Is it possible for me to teach all of these receivers how to implement the workaround you mention? Or do you reckon the fix is too complicated, and they have to settle for a fixed height (a very sub-optimal solution)?

Any answers welcome. Also: if I have not provided enough information, tell me, and I'll expand on it.

Thanks. Erik
Feb 5 '09 #3

P: 2

my task with the iframe seems difficult, from googling the issue.

Therefore, I am trying to think workarounds.

One possibly important issue here, is that the content that is produced on my site, will ONLY be used by other sites using IFRAME. That means, I can do whatever I want with the pages that are going to show in the iframe windows (except, due to contant issues, making them the same height...)

What I'm thinking is:

Is it possible to set up some kind of service, that automatically starts when a page is called for at my server, and first feeds some information to the recipient (i.e. document heigth). THen the recipient would use this information when setting up the page with the iframe, thus being able to set the correct iframe height?

Dunno if this makes sense, as I am not too familiar with the technicalities here, but if you need more information, let me know.


Feb 5 '09 #4

Expert Mod 15k+
P: 16,027
There's a few workarounds based on the fragment identifier or using an extra iframe. They would usually involve some sort of collaboration between the two domains. One way you could get it to work is if you have an iframe within your page content that has the same domain as the parent domain. The other is described here.
Feb 7 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.