html_code_clinic thread: How to get round an Access denied error using parent.ducment
Here's a javascript function I use to dynamically resize an IFrame from
within the IFrame...
function resizeIFrame(w)
{
if (parent.document.location != document.location)
{
var oFrame = parent.document.getElementById("customFrame");
if (typeof(oFrame) == 'object')
{
oFrame.style.width = (document.body.scrollWidth + w);
oFrame.style.height = (document.body.scrollHeight + w);
}
}
}
I use it because I'm generating content on the fly in javascript on the
client, and I want the IFrame containing the content to be a close fit.
There's a test in there to make sure the code running is within a child
document and that there is actually an IFrame object named "customFrame"
before it tries to change the size.
When I try this out using a container and child on the same machine all is
well. It also works when the document is not in an IFrame and when the
parent has no IFrame named "customFrame".
When the IFrame content is on a different server to the parent I get an
error "Access denied" when I try to test the parent.document.location to
see if it's the same as the running document.
Unfortunately this is exactly where it will be used in a real deployment,
so I need a fix.
Does anyone know how to get and set properties in the parent document when
the parent and child are on different domains?
Brian Lowe
---------@