P
Paul McAleer
Hello all,
I'm trying to resize an iframe dynamically based on content. The
content lives on a different box within the same domain, and I've
already done a ton of research on the usual suspects: document.domain,
etc.
The parent page lives at https://www.mydomain.com/, and the child lives
at https://application.mydomain.com/application/.
Originally I had the iframed content specify its document.domain to be
the same as the parent's, "mycompany.com". That worked in that I
*seemed* to be able to view the scrollHeight of the child iframe but,
at least in IE6, it was reporting an incorrect value.
So I added code in the child iframe to call the parent's
iFrameHeight(), which is largely based on code from experts-exchange.
However, this throws a permission denied error for me even though the
domains are set to be the same.
I'm pretty much at my wit's end with this thing, and any assistance
would be appreciated.
CODE:
In the parent:
---
document.domain = "mycompany.com";
function iFrameHeight() {
h = 0;
if (document.domain.indexOf(".") > 0) {
if(document.getElementById && !(document.all)) { // Moz/Firefox only
h =
document.getElementById('content_frame').contentDocument.body.offsetHeight
+ 120;
document.getElementById('content_frame').style.height = h + "px";
window.scrollTo(0,0);
} else if(document.all) { // IE 6 and lower
h = document.all.content_frame.document.body.clientHeight;
document.getElementById('content_frame').style.height = h;
window.scrollTo(0,0);
}
}
}
//window.onresize = iFrameHeight;
(I commented out the window.onresize stuff until I get this fixed.)
In the child (iframed content):
I'm trying to resize an iframe dynamically based on content. The
content lives on a different box within the same domain, and I've
already done a ton of research on the usual suspects: document.domain,
etc.
The parent page lives at https://www.mydomain.com/, and the child lives
at https://application.mydomain.com/application/.
Originally I had the iframed content specify its document.domain to be
the same as the parent's, "mycompany.com". That worked in that I
*seemed* to be able to view the scrollHeight of the child iframe but,
at least in IE6, it was reporting an incorrect value.
So I added code in the child iframe to call the parent's
iFrameHeight(), which is largely based on code from experts-exchange.
However, this throws a permission denied error for me even though the
domains are set to be the same.
I'm pretty much at my wit's end with this thing, and any assistance
would be appreciated.
CODE:
In the parent:
---
document.domain = "mycompany.com";
function iFrameHeight() {
h = 0;
if (document.domain.indexOf(".") > 0) {
if(document.getElementById && !(document.all)) { // Moz/Firefox only
h =
document.getElementById('content_frame').contentDocument.body.offsetHeight
+ 120;
document.getElementById('content_frame').style.height = h + "px";
window.scrollTo(0,0);
} else if(document.all) { // IE 6 and lower
h = document.all.content_frame.document.body.clientHeight;
document.getElementById('content_frame').style.height = h;
window.scrollTo(0,0);
}
}
}
//window.onresize = iFrameHeight;
(I commented out the window.onresize stuff until I get this fixed.)
In the child (iframed content):