Pass custom arguments to window.open in case of Ed

2019-03-06 03:53发布

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条回答
狗以群分
2楼-- · 2019-03-06 04:10

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;
查看更多
登录 后发表回答