Javascript created IFrame document, weird domain issue

R

Robert Oschler

I have an IFrame whose document is created completely by Javascript code at
runtime. The document in the IFrame accesses Javascript functions in the
top level document. This works fine most of the time. But every now and
then, when I hit the back button, the browser suddenly thinks the Javascript
created document in the IFrame is not from the same domain as the topmost
document, and therefore I start getting "permission denied" errors when I
try to access the top level document's Javascript functions.

If I look at the IFrame document's properties (Mozilla->This Frame->View
Info), it shows the expected URL with a domain name that matches the top
level document.

Anyone got any ideas on why this is happening and what I can do to prevent
it?

Thanks.
 
V

VK

Robert said:
I have an IFrame whose document is created completely by Javascript code at
runtime. The document in the IFrame accesses Javascript functions in the
top level document. This works fine most of the time. But every now and
then, when I hit the back button, the browser suddenly thinks the Javascript
created document in the IFrame is not from the same domain as the topmost
document, and therefore I start getting "permission denied" errors when I
try to access the top level document's Javascript functions.

If I look at the IFrame document's properties (Mozilla->This Frame->View
Info), it shows the expected URL with a domain name that matches the top
level document.

Anyone got any ideas on why this is happening and what I can do to prevent
it?

Reminds me a reversed case of this one:
<http://groups-beta.google.com/group...ript+author:VK&rnum=39&hl=en#186b0f8e07897987>

Try:
1) iframe has only ID (no NAME) property
2) don't use any names for addressing:
window.frames[0].functionName (to address a function in the main
window)
self.parent.functionName ((to address a function in iframe).


ALSO: upon reloading (or form submission) frames and specially iframes
tends to not remember their parents.
 
R

Robert Oschler

VK said:
Reminds me a reversed case of this one:
<http://groups-beta.google.com/group/comp.lang.javascript/browse_frm/thread/
8005d8ef77288c39/186b0f8e07897987?q=group:comp.lang.javascript+author:VK&rnu
m=39&hl=en#186b0f8e07897987>

Try:
1) iframe has only ID (no NAME) property
2) don't use any names for addressing:
window.frames[0].functionName (to address a function in the main
window)
self.parent.functionName ((to address a function in iframe).


ALSO: upon reloading (or form submission) frames and specially iframes
tends to not remember their parents.

VK,

Thanks!

I'm not sure if understand the "self.parent.functionName()" statement here.
Your note says "to address a function n iframe", but wouldn't that address a
function in the iframe's parent instead? (Assuming "self" here refers to
the iframe)

Also, based on your "upon reloading" warning, wouldn't the
"self.parent.functionName()" be problematic?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,835
Latest member
KetoRushACVBuy

Latest Threads

Top