This may seem like a JavaScript 101 topic but this was currently something I struggled with the last couple of days, and I thought that if finding a solution for this task was hard for me then it might also be hard for other people.

What I was looking to do was this: Open a new window (child) that displays data that are passed from the initial window (parent).

I was able to find solutions on how to read values out of textboxes between the parent window and the child, but that would not work for me. I need to be able to pass arrays of objects and other values that are too big or just won’t fit in a textbox.

Here is the solution I came up with:

In the parent window before you call window.open() to create a new browser window/tab you need to create a new property on the window object.
window.foo = arrOfObjects;
window.open( ‘newWindowToShow.html’, ” );

Now to access the new property in the child window, you just need to reference the window.opener object.
var myNewListOfObjects = window.opener.foo;

That’s it. Now in the your new (child) window/tab you will have access to you values.

Make sure that when you are done using the values in your new window that you set the values to null. I noticed some issue when I didn’t do that.
window.opener.foo = null;

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>