Reputation: 12387
window.frames["frame_name"]
doesn't work<iframe id="replaceme" name="frame_1"></iframe><br />
$("body").append(window.frames[0].name + "<br />");
$("body").append(window.frames["frame_1"].name + "<br />");
$("body").append( (window.frames[0] == window.frames["frame_1"]) + "<br />");
$("#replaceme").remove();
$("body").append('<iframe name="frame_1"></iframe><br />');
$("body").append(window.frames[0].name + "<br />");
$("body").append(window.frames["frame_1"].name + "<br />");
$("body").append( (window.frames[0] == window.frames["frame_1"]) + "<br />");
Is this a bug or expected behavior? It works fine in Opera, Safari, Chrome. Any suggestions of how to work around it in Firefox?
Upvotes: 0
Views: 5574
Reputation: 35074
This is a bug, as you already figured out.
There are two options for workarounds, in addition to not reusing frame names:
1) You could delete window.frames["frame_name"]
either when removing the relevant frame from the DOM or right before you access window.frames["frame_name"]
. Either one should work in Firefox, but I can't speak to other browsers.
2) You could switch to using document.getElementById("frame_id").contentWindow
. The big problem there is IE compat, especially in older IE versions...
Upvotes: 4