I have a page with a remote (another domain) document in an iFrame.
Now i want to resize the iFrame to the remote document height so no scrollbars apear. Due too security issues this seems impossible. My programming skills are not that great.. and WebDeveloper.com is my last resort to find a solution to this problem.
I have a script wich works with local files, but not remote:
[CODE]// addept iframe height to content height
function getDocHeight(doc) {
alert(“getDocHeight called!”);
var docHt = 0, sh, oh;
if (doc.height) docHt = doc.height;
else if (doc.body) {
if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
if (sh && oh) docHt = Math.max(sh, oh);
}
return docHt;
}
function setIframeHeight(ifrm) {
alert(“setIframeHeight called!”);
var iframeWin = window.frames[ifrm];
var iframeEl = document.getElementById ? document.getElementById(ifrm): document.all ? document.all[ifrm]: null;
if ( iframeEl && iframeWin ) {
alert(iframeWin.document.scrollHeight);
iframeEl.style.height = “auto”; // helps resize (for some browsers) if new doc is shorter than previous
var docHt = getDocHeight(iframeWin.document);
if (docHt) iframeEl.style.height = docHt + 30 + “px”; // add to height to be sure it will all show
}
}
The function setIframeHeight(); was called from the iframe.document (local).
Now i’ve added an onload=”setIframeHeight(iframeId);” in my iframe tag.
Does anyone know how to make this work with remote documents?
NOTE: I have access to the remote document.
Thanks in advance!