Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all good evening,
I have parent window "ParentForm" & child window "Popup.aspx". From the parent window in a button (onClientClick") i am opening the Child window. thats ok.
Now the problem is when user is press escape that popup.aspx will close that's also i have done.
But while closing the Child window, My control focus need to be on Parent window button(btnSubmit) button. I google but not got a good idea, any body plz help me.


This is the code i am using to close the popup window

JavaScript
function doClose(e) {
            if (!e) e = window.event;
           
            if (e.keyCode) {
                if (e.keyCode == "27") {
                    
                    window.close();
                }
            }
            else if (e.charCode) {
            if (e.charCode == "27") {
                
                window.close();
            }
            }
        }        document.onkeydown = doClose;

The above function is called in popup.aspx (body onKeydown="doClose(evt");"


Thanks in advance, sorry for the english.
Posted
Updated 25-Apr-13 4:20am
v4
Comments
TorstenH. 25-Apr-13 10:21am    
added some style and a sufficent tag "javascript".
Prasad Khandekar 25-Apr-13 10:28am    
try window.opener.document.getElementById('btnSubmit').focus();

1 solution

Look at the window object: http://www.w3schools.com/jsref/obj_window.asp[^].

You will find exactly two members which will help you to achieve what you want:
http://www.w3schools.com/jsref/prop_win_parent.asp[^],
http://www.w3schools.com/jsref/met_win_focus.asp[^].

Please try.

—SA
 
Share this answer
 
Comments
Espen Harlinn 25-Apr-13 19:26pm    
5'ed!
Sergey Alexandrovich Kryukov 25-Apr-13 19:44pm    
Thank you, Espen.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900