Reputation: 181
I already developed application to open popup using below code,
var url = 'child.html';
var args = ['value'];
var options='height:150px;width:300px'
window.openModalDialog(url,args,options);
Am able to read argument from openModalDialog using below code
var args = window.dialogArguments;
var arg = args[0];
Now am migrating application to Chrome. As per document window.openModalDialog not supported in Chrome. So, I plan to replace it with window.open. Now am facing issue when I try to get argument. Because, am unable to get argument using window.dialogArguments. I tried with
window.opener and parent.window.opener
to get argument. It return Cross Origin error. how can I get arguments from window.open.?
Upvotes: 1
Views: 4431
Reputation: 2077
With window.open
you should save the opener into a variable, and then you can access the arguments.
var url = 'child.html';
var args = ['value'];
var options='height:150px;width:300px'
let newWindow = window.open(url,args,options);
And the arguments will be inside newWindow.location
object.
NOTE: This WILL NOT work if your window opens in a different domain, since that tries to break a security policy called CORS.
Upvotes: 1