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.
The key idea is
function getInnerHeight( iframe){
var d=iframe.conten tWindow ?
iframe.contentW indow.document :
iframe.contentD ocument;
var h=0;
if(d){
if(d.documentEl ement && d.compatMode &&
d.compatMode==" CSS1Compat")
h=d.documentEle ment.scrollHeig ht;
else if(d.body)
h=d.body.scroll Height;
if(h) h+=getInsets(d) ;
} return (h||300)+"px"; //300 is a default value
}
<iframe src="javascript :top.writeSomeT ext()"
width="559"
onload="this.st yle.height=getI nnerHeight(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.contentW indow.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.
The key idea is
function getInnerHeight( iframe){
var d=iframe.conten tWindow ?
iframe.contentW indow.document :
iframe.contentD ocument;
var h=0;
if(d){
if(d.documentEl ement && d.compatMode &&
d.compatMode==" CSS1Compat")
h=d.documentEle ment.scrollHeig ht;
else if(d.body)
h=d.body.scroll Height;
if(h) h+=getInsets(d) ;
} return (h||300)+"px"; //300 is a default value
}
<iframe src="javascript :top.writeSomeT ext()"
width="559"
onload="this.st yle.height=getI nnerHeight(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.contentW indow.document returns "access is denied" error.
Do you have any idea how to solve this problem?
Thanks
Dom
Comment