Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I made a window.opener to return a value to the parent page. I used window.showModalDialog() to open the pop up. I know that it goes to my javascript function since I put an alert and the alert pops up. The window.opener does not send the value back to the textbox that I assigned and it does not even close. Here is my javascript code (this is an inline javascript):

XML
<script language="javascript" type="text/javascript">

            function SelectAndClose()
            {
                txtValue = document.getElementById('_browseTextBox').value;

                //window.returnValue = txtValue.value;
                window.opener.document.getElementById('txtRaw').value = txtValue;
                self.close;
                alert("Hello");
                //return false;
            }

        </script>


Here is my function call to this javascript:

<asp:Button ID="_selectButton" Text= "OK" runat="server" Width="138px" OnClientClick="javascript:SelectAndClose()"/>


Thanks!
Posted
Comments
Sergey Alexandrovich Kryukov 15-Aug-12 14:02pm    
How can it possibly work? You are working with a window which in general case does not have an opener.
--SA

1 solution

You probably misunderstood the property window.opener. If the content you show is placed in some HTML page, and you open this page with a browser using some URI (file name of HTTP/HTTPs URL, does not matter), it is apparent that the opener is null. There is no an "opener", which could be some "other window" which opened your browser window.

To understand it, please see:
http://www.w3schools.com/jsref/prop_win_opener.asp[^].

—SA
 
Share this answer
 
Comments
Franco Cipriano 15-Aug-12 16:31pm    
So i should assign a variable to catch the window.open()?
Sergey Alexandrovich Kryukov 15-Aug-12 17:21pm    
window.open() is a method, not clear what to catch and why? How assigning a variable can catch anything at all? I do not believe you understand yourself what you are asking about.

I fully answered your question.
If you need something else: first, understand and explain your goal. What exactly windows do you want to reach and why?
--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