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.
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.
Share Improve this question edited May 23, 2017 at 12:29 CommunityBot 11 silver badge asked May 1, 2011 at 12:27 AnkurAnkur 51.2k114 gold badges248 silver badges316 bronze badges 1- what does the array contain? If it's simple items (e.g. numbers) see my answer. – user447356 Commented May 1, 2011 at 12:41
2 Answers
Reset to default 3You 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.
You can also pass it on the URL as well, for example:
window.open("http://localhost:8081/myapp/Query.action?arr=" + query.join(","), "mywindow", ...
This will pass it as ma separated list that can be read in the target page.