469,290 Members | 1,866 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,290 developers. It's quick & easy.

Dynamic resizing of iframes based on content height

Hi,

Does anyone know of how I could dynamically resize an iframe based on
the content's height (for IE) so that no scrollbar appears for the iframe?
The content will be from a different domain. I have searched on the web and
have seen solution like this

<script>
function resize() {
var oframe = document.getElementById("frameID");

//***
//var odoc = oframe.document; //(1)
var odoc = oframe.Document; //(2)

var obody = odoc.body;

oframe.height = obody.scrollHeight;
}
</script>

The html :
<iframe onload="resize()" src=http://different.comain.content border="0"
....... > </iframe>

I have seen 2 solutions on the web, the only difference being lines (1) and
(2) get substitued.
My browser is version IE 6.

It seems that the solution with line (2) works perfectly when the content is
from the same domain but gets a Permission Error if the domain is different.

When the content is from a different domain solution (1) does not give
Permission error, but instead the scrollHeight is significantly smaller
than the actual content. Even if the content is from the same domain it
still gives the wrong size.

So my question is
1) What is the difference between oframe.document and oframe.Document, why
does it give different results?

2) More importantly, how can I dynamically adjust the iframe size based on
the content height from a different domain?
Jul 23 '05 #1
1 7022
Peter wrote:
Does anyone know of how I could dynamically resize an iframe based on
the content's height (for IE) so that no scrollbar appears for the iframe?
The content will be from a different domain. [...]


The Same Origin Policy prevents this almost certain violation of author's
rights. Your goal would be a contradiction to the purpose of an iframe
anyway.
PointedEars
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by khothikhe | last post: by
1 post views Thread by Paul Fi | last post: by
3 posts views Thread by =?Utf-8?B?UiBSZXllcw==?= | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.