Javascript created IFrame document, weird domain issue

Discussion in 'Javascript' started by Robert Oschler, Aug 3, 2005.

  1. 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.
    Robert Oschler, Aug 3, 2005
    #1
    1. Advertising

  2. Robert Oschler

    VK Guest

    Robert Oschler wrote:
    > 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/comp.lang.javascript/browse_frm/thread/8005d8ef77288c39/186b0f8e07897987?q=group:comp.lang.javascript+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.
    VK, Aug 3, 2005
    #2
    1. Advertising

  3. "VK" <> wrote in message
    news:...
    >
    >
    > 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.
    Robert Oschler, Aug 3, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    480
  2. Daedalous
    Replies:
    3
    Views:
    651
    Daedalous
    Jan 16, 2004
  3. Cindy Lee
    Replies:
    2
    Views:
    132
  4. Vincent van Beveren

    IFRAME initalization and stylesheet in DOM-created IFRAME

    Vincent van Beveren, Jun 14, 2004, in forum: Javascript
    Replies:
    7
    Views:
    187
  5. Paul  McAleer

    document.domain / iframe woes

    Paul McAleer, Aug 18, 2006, in forum: Javascript
    Replies:
    0
    Views:
    94
    Paul McAleer
    Aug 18, 2006
Loading...

Share This Page