0

Simple thing happens with a Firefox 22 and higher: if you have a frame with a name "name1" and you renamed it to "name2" then the "name1" still will be present in a window.frames array but it's value would be undefined. The same thing happens if you call delete window.frames["name1"];.

The problem is that you couldn't directly place any item into frames array with a name "name1" in this case. Also you couldn't add the property name1 into that window object. The only way to do this is change the some frame name to "name1". However our current application logic need to access the same frame both by "name1" and "name2" in the same time.

Here the sample: http://jsfiddle.net/tigeral/2VwFV/2/ .Please compare results in both Firefox 21 and 22.

Does anyone know a workaround how to make follow code working ?

window.frames["name1"].name = "name2";
// what I need to do here ?    
window.frames["name1"] = window.frames["name2"];
alert(window.frames["name1"].name);

P.s. the similar question was already posted on Stack Overflow, but my case requires a different solution. window.frames["frame_name"] doesn't work in Firefox when frame has been removed and readded

tigeral
  • 16
  • 2

1 Answers1

0

I have found a solution. If you need to force set the frames["name1"] value just once you can use Object.defineProperty(frames, "name1", {value: frames["name2"]}); sentance. But if you also want to unlock the frames["name1"] value for the future changes then you'd better use Object.defineProperty(frames, "name1", {value: frames["name2"], writable: true});

You can check this solution here: http://jsfiddle.net/2VwFV/3/ or in sample below:

window.frames["name1"].name = "name2";
Object.defineProperty(frames, "name1", {writable: true});    
window.frames["name1"] = window.frames["name2"];
alert(window.frames["name1"].name);

More info about Object.defineProperty(...) method could be found by follow link: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty

tigeral
  • 16
  • 2