📜 ⬆️ ⬇️

Problem with javascript arrays in IE during interwindow communication

With an amusing problem faced. I have on the site page a certain array of objects, in general, not a simple construction of the form:
dataArray = [
{id1:data1},
{id2:data2},
{id3:data3}
]

themselves do not matter.

The program has such a moment when the given array should be transferred to the opened window. It is natural to write to the window code:
dataArray = window.opener.dataArray;

The problem is that both window.opener.dataArray and, accordingly, dataArray are no longer arrays, i.e .:
window.opener.dataArray instanceof Array // false
dataArray instanceof Array // false, .
and accordingly lose all methods inherent in arrays.

Of course, there is a solution - to pass an array through JSON, but it’s some kind of ... clumsy something ...

')

Source: https://habr.com/ru/post/85700/


All Articles