D
Dominic
Hi everybody,
My goal is to set the height of the iframe to fit its content. There
was an earlier posting which gave some useful insights.
http://groups.google.com/groups?hl=...?hl=en&lr=&ie=UTF-8&q=Calculating+IFrame+size
The key idea is
function getInnerHeight(iframe){
var d=iframe.contentWindow ?
iframe.contentWindow.document :
iframe.contentDocument;
var h=0;
if(d){
if(d.documentElement && d.compatMode &&
d.compatMode=="CSS1Compat")
h=d.documentElement.scrollHeight;
else if(d.body)
h=d.body.scrollHeight;
if(h) h+=getInsets(d);
} return (h||300)+"px"; //300 is a default value
}
<iframe src="javascript:top.writeSomeText()"
width="559"
onload="this.style.height=getInnerHeight(this)"></iframe>
It works perfectly if the src of iframe is some local content.
Unfortunately, if I put src="http://www.yahoo.com", the line
iframe.contentWindow.document returns "access is denied" error.
Do you have any idea how to solve this problem?
Thanks
Dom
My goal is to set the height of the iframe to fit its content. There
was an earlier posting which gave some useful insights.
http://groups.google.com/groups?hl=...?hl=en&lr=&ie=UTF-8&q=Calculating+IFrame+size
The key idea is
function getInnerHeight(iframe){
var d=iframe.contentWindow ?
iframe.contentWindow.document :
iframe.contentDocument;
var h=0;
if(d){
if(d.documentElement && d.compatMode &&
d.compatMode=="CSS1Compat")
h=d.documentElement.scrollHeight;
else if(d.body)
h=d.body.scrollHeight;
if(h) h+=getInsets(d);
} return (h||300)+"px"; //300 is a default value
}
<iframe src="javascript:top.writeSomeText()"
width="559"
onload="this.style.height=getInnerHeight(this)"></iframe>
It works perfectly if the src of iframe is some local content.
Unfortunately, if I put src="http://www.yahoo.com", the line
iframe.contentWindow.document returns "access is denied" error.
Do you have any idea how to solve this problem?
Thanks
Dom