Click to See Complete Forum and Search --> : AJAX Iframes


Shawazi
06-11-2007, 05:31 PM
Why would an iframe become unaccessible after creating, destroying, and then re-recreating it? On the first creation I can access it fine with this line:

//obj gets HTML with the IFrame
obj.innerHTML = object.ResponseText;

//access iframe
var myFrame = window.frames['frameName'];

//access DIV inside iframe
var myDIV = myFrame.document.getElementById('innerDIV');



I then do this:


obj.innerHTML = "";


Then I can toggle to re-rerun the first code block which will then no longer work.

Shawazi
06-11-2007, 10:06 PM
I changed to using this code and it worked:


for (i=0;i<window.frames.length;i++) {
var curName = window.frames[i].name;
if (curName == "bgFrame") {
var curFrame = window.frames[i];
}

}


for some reason I need to loop through the dom for it to work after destroying the frame and bringing it back. any ideas?

JPnyc
06-11-2007, 10:41 PM
That's what I would've surmised, the name already existed in the window objects

Shawazi
06-11-2007, 10:42 PM
When I remove it out of the window why would it still be in that object? If I run the loop with it gone it does not come up.

JPnyc
06-11-2007, 11:05 PM
I think it depends how you remove it. How did you remove it?