View Full Version : Displaying content in an Iframe from a different domain

12-10-2005, 10:24 PM
We are having a problem displaying content in an iframe from another domain. What we want to do is have the iframe resize itself to the height of the displayed content. If the page is too long to display without a scrollbar, we'd like the scrollbar to occur at the page level, not the iframe level. Is there a way to do that? NOTE: We've been able to accomplish this as long as the iframe content is from the same domain as the parent page, but not when the iframe content is from a different domain. There appears to be some issue crossing domains that we have been unable to identify and solve.

12-10-2005, 10:27 PM
Javascript cannot go across domains which is why you can't get it to work. I'm assuming you are trying to read the offsetHeight of the page in the iframe then set the height of the iframe on the parent page to the offsetHeight.

12-11-2005, 01:18 PM
You are correct - that is what we've been trying. Is there another way to accomplish this? As a workaround we have been considering trying to set the height of the iframe to some ridiculous number and then use Javascript to always scroll it to the top. Since we would not be depending upon the page size from another domain, would this work?

12-12-2005, 12:08 AM
To scroll to the top you would have to access the page in the iframe and again you will get an error because its cross domain. Do you even have permission from the owner if you could put their page on your site?

12-12-2005, 01:39 PM
Yes, we have permission - we pay a monthly fee in order to use their services. The service providers have not been able to come up with a solution for this either. The page runs content from 2 different websites inside the iframe based on what the user selects. We've asked both providers for a solution. Other users of their services run the entire pages hosted on their servers. The company that wants this solution does not want to do it that way (not my choice on this one). I've also tried using the <object> tag instead of an iframe - same problem, probably for the same reason. Would it be possible to do this with another scripting language such as Perl or VBScript?