Pass custom arguments to window.open in case of Edge browser

拟墨画扇 提交于 2019-12-02 20:06:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!