0

I am calling the parent page javascript function from child window with code below, which displays some alert message on parent page and closes the child window.

window.opener.CallAlert("test is"+test);
opener.focus();
self.close();

What is happening with above code snippet is alert comes on parent window but focus remains on child window. i need explicitly go to parent window. Once I click ok on alert child window closes.

Everything is fine but I want the to focus on parent window once i call the window.opener.CallAlert() from child window.

Edit

Looks like opener.focus(); works on IE but not mozilla. Any workaround for firefox?

MarthyM
  • 1,839
  • 2
  • 21
  • 23
emilly
  • 10,060
  • 33
  • 97
  • 172

3 Answers3

1

It would appear that this is not guaranteed to work and is at the discretion of the browser.

See this thread: window.opener.focus() doesn't work

Community
  • 1
  • 1
Kildareflare
  • 4,590
  • 5
  • 51
  • 65
0

just try the obvious:

window.opener.focus();
hereandnow78
  • 14,094
  • 8
  • 42
  • 48
0

try with delay setTimeout(function(){self.close()},300) and then display alert on parent page. It will schedule to close the current window after some delay automatically with display of alert message on parent signal

M Sach
  • 33,416
  • 76
  • 221
  • 314