javascript_howto thread: How to get round an Access denied error using parent.document
--0-1228273665-1027115288=:99245
Content-Type: text/plain; charset=us-ascii
Hello Brian,
about your problem, there is no way to access an IFrame from a different domain other than the one in which it is located, this is
due to security issues of the Javascript language. Sorry for the delayed reply(haven't been around for a while).
Brian Lowe <brian.lowe@i...> wrote: 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 (silently terminating) if the document is not in an
IFrame or 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
---------@
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
---------------------------------
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes