Search code examples
javascriptarrayswindow.open

How do I pass any array to a window being opened with window.open()


I have any array called query[]

I am opening a new window with:

  window.open("http://localhost:8081/myapp/Query.action","mywindow","menubar=1,resizable=1,width=600,height=400");

How do I pass this array to the new window so I can use it there.

EDIT: I just found this, Pass array to Window which will probably provide the answer.

EDIT2: the answer provided in question 2487420 doesn't seem to work, I am using FireFox and openDialog never opens a new window

New Requirement: This only has to work on FireFox because I am only using it for testing.


Solution

  • You can't "pass" the array, but you can make it available as a global (or via a global), and your new page can use something like:

     var theArray = window.opener.theArray;
    

    to get access to it.

    Alternatively, you could pass the array through as a list of parameters, but if it's not otherwise interesting to the server then that would be a little wasteful.