window.opener not working in chrome & IE

早过忘川 提交于 2019-12-23 05:22:26

问题


I have one child popup. From this child popup I am sending some values from child popup to textbox of parent page.

javascript is working fine in firefox but not working in chrome & IE

Bellow is the javascript

function submitValues(value1,value2)
{
  window.close();
  window.opener.document.getElementById("value1Id").value = value1;
  window.opener.document.getElementById("value2Id").value = value2;
}

I am not able to figure out that what is the problem.


回答1:


You can pass arguments to showModalDialog function. Simply pass window object as an argument.

window.showModalDialog(theURL, window);

Yo can access the arguments from the modal window using dialogArguments. See: http://msdn.microsoft.com/en-us/library/ms533723%28VS.85%29.aspx

var openerWindow = window.dialogArguments;



回答2:


Can you try the below function if it works The window.close will close the window

function submitValues(value1,value2)
{

   window.opener.document.getElementById("value1Id").value = value1;
   window.opener.document.getElementById("value2Id").value = value2;
   window.close();
}


来源:https://stackoverflow.com/questions/12142392/window-opener-not-working-in-chrome-ie

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