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,801
  • 2
  • 20
  • 23
emilly
  • 9,488
  • 28
  • 87
  • 161

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,372
  • 5
  • 48
  • 62
0

just try the obvious:

window.opener.focus();
hereandnow78
  • 13,584
  • 8
  • 40
  • 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
  • 31,956
  • 72
  • 207
  • 306