I have made a function for automatically resizing of an iFrame. However, it works only when the content of iFrame is set to be from another web-site (could still be on the same server)... Guess there are some problems with calling of the function..
The iFrame and the resizing function is in the file Mainpage.aspx, the function is like this:
function setIframeHeight(iframe) {
if (iframe) {
var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow;
if (iframeWin.document.body) {
iframe.height = 17 + iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight;
}
}
};
It is called in the Page_load event:
ifrMain.Attributes.Add("onload", "setIframeHeight(document.getElementById('" + ifrMain.ClientID + "'));")
When the iFrame-content is in the same web as Mainpage.aspx, (http://aserver/web1/page1.aspx) it does not resize to fit the lenght of the content. When the content of the iFrame is from another web site (external or internal, i.e. http://aserver/web2.page1.aspx), it resizes just fine. Why?
I'm not deep into client-side scripting, may be I've missed something basic here??
Regards, John Martin