Dynamic resizing of iframes based on content height

P

Peter

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?
 
T

Thomas 'PointedEars' Lahn

Peter said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top