问题
From a parent window say A, trying to open another window - ChildWindow.htm using window.open. I am unable to pass string value from A.
var dialog = window.open("Child_Window.htm?", "title", "width=550px, height= 350px,left=100,top=100,menubar=no,status=no,toolbar=no");
dialog.MyVariable = "some string value";
dialog.opener = window;
In Child window, I get
window.MyVariable
as undefined
回答1:
The code snippet shown in the question works fine for Chrome browser. And to pass the context to another window in case of Edge browser, follow the below method.
declare a global variable in the parent window
var myVariable;
dialog = window.open("Child_Window.htm", "title", "width=550px, height= 350px,left=100,top=100,menubar=no,status=no,toolbar=no");
Set the variable
myVariable = "Sample String Value";
And, access the varable in the child window using window.opener, like -
var myVar = window.opener.myVariable;
来源:https://stackoverflow.com/questions/34947586/pass-custom-arguments-to-window-open-in-case-of-edge-browser