dcsimg
www.webdeveloper.com
Results 1 to 6 of 6

Thread: I cannot call the same iframe twice

  1. #1
    Join Date
    Apr 2009
    Posts
    4

    I cannot call the same iframe twice

    Hi all
    I have an iframe dynamically created that I can access without any
    problem using: window.frames['frameName'].document.

    Now, if I call this command, remove the iframe from the DOM and
    recreate it (with the same name), the same command window.frames
    ['frameName'].document returns null (though, the iframe exists in the
    DOM, the name used to access it is correct... ).

    I suspect the iframe (or window.frames['frameName']) is not
    completely cleared when I remove it from the DOM as if I run
    window.frames['frameName'].document before it has ever been created,
    firebug returns a type error (TypeError: window.frames['frameName'] is
    undefined). However, the same command returns null (without error)
    after creation, deletion and creation again of the same iframe.

    is there something I need to do when the iFrame is being removed to
    completely clear the memory - I really don't get what is happening -
    but I am a beginner in JavaScript.

    Thanks in advance for any type of hint.
    Cheers
    Christophe (using FF 3.0.8)

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Can you show the code you use for creation and deletion?

  3. #3
    Join Date
    Apr 2009
    Posts
    4
    I develop using Ext framework and my iframes are embedded in a window components (for an example, you can open a window from http://extjs.com/deploy/dev/examples...p/desktop.html)

    the close function for the window looks like:
    close : function(){
    if(this.fireEvent("beforeclose", this) !== false){
    this.hide(null, function(){
    this.fireEvent('close', this);
    this.destroy();
    }, this);
    }

    and the doc says that this
    "Closes the window, removes it from the DOM and destroys the window object".

    Now, I had a closer look using frame index instead of names, and I do not get the same problem (i.e. window.frames[0] works fine when if I open an iframe, close it and open it again). But I need to refer to the iframe using the names attribute, no luck.

    Cheers and thanks for the reply
    Christophe

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    What does window.frames[0].name give?

  5. #5
    Join Date
    Apr 2009
    Posts
    4
    well, it gives the correct name of the iframe (after create, remove, recreate, ...) Can't see anything unusual there.
    C.

  6. #6
    Join Date
    Apr 2009
    Posts
    4
    Thanks for your help fang.
    It seems that "delete window.frames[frameName];" after closing the window does the trick.
    C.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles