window.opener not working in chrome & IE

2019-06-09 01:49发布

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.

2条回答
2楼-- · 2019-06-09 02:25

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();
}
查看更多
可以哭但决不认输i
3楼-- · 2019-06-09 02:47

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