I have a scenario like this.
Window 1->opens->modal popup->opens-> window 2.
Modal popup is launched using showmodaldialog method from window 1. From the modal popup a normal window (window 2) is launched using "window.open" method. On launching the window 2, the modal popup is closed using self.close()
in the popup window's javascript.
Now the windows open are window 1 & window 2. I want to transfer the focus of the window 1 from window 2. is there anyway this can be done?
I have removed other programming code due to security restrictions at the workplace. However, given below is the gist of the code for the scenario I have explained above. Please let me know if there is anything that can be done to solve this problem?
Following is my code:
Parent Window (window 1):
<html> <head><title> Parent Window <title> <script> function show_popup(){ base_win=window; var win1=window.showModalDialog("Child_Window 1.html",base_win,"dialogHeight:500px;dialogWidth:500px;dialogLeft:300"); } </script> </head> <body> This is the parent Window <input type="button" id="button1" value="click this" onclick="javascript:show_popup();"> </body> </html>
Modal Popup Window:
<html> <head> <title>Child Window 1</title> <script> function show_window(){ var win1=window.open("Child_Window 2.html",""); self.close(); } </script> </head> <body> This is the Child Window 1 <br> <br> <input type="button" id="but1" value="click this" onclick="javascript:show_window();"> </body> </html>
Child Window (window 2):
<html> <head> <title>Child Window 2</title> <script> function goto_parent(){ var w = window.opener; window.opener = self; w.focus(); } </script> </head> <body> This is the child Window <input type="button" id="but1" value="parent window" onclick="javascript:goto_parent();"> </body> </html>