I need to open a new browser window from another browser window and access the object from the parent window in the child window. Therefore, when the child window loads, I use the openener property to access the object from the parent. Works well in Firefox, but in IE, array properties are converted to objects.
eg.
function openChild() { window.open(window.document.location, '_blank'); } var data = { myArray: [] }; $(document).ready(function() { alert('data is array: ' + (data.myArray instanceof Array)); alert('prototype: ' + (Object.prototype.toString.call(data.myArray))); if (window.opener) { var parentData = window.opener.data; alert('parent data is array: ' + (parentData.myArray instanceof Array)); alert('parent prototype: ' + (Object.prototype.toString.call(parentData.myArray))); } });
When the child window opens in IE, the result will be
data is array: true prototype: [object Array] parent data is array: false parent prototype: [object Object]
and the result in Firefox is
data is array: true prototype: [object Array] parent data is array: false parent prototype: [object Array]
One job too serializes the object in JSON, passes the string, and then deserializes. However, any methods of the object are lost.
What else can I do except sit around talking about how IE is the scourge of web development?
source share