Click here to Skip to main content
15,895,256 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi All,

I have a page1.aspx, and page2.aspx. I am showing page2.aspx as popup from page1.aspx.
the page2.aspx has a button, Now what I need is when I click on the button in page.2aspx (popup) I need to close this popup (page2.aspx) and call the javascript function which is in page1.aspx. page1.aspx is the page which shows the popup.

Please help me in this regard.

Thanks in anticipation.

Sri
Posted
Updated 6-Jun-11 22:52pm
v2
Comments
Sri9797 7-Jun-11 4:55am    
It seems Koushik, u edited something to my question. right
Sri9797 7-Jun-11 4:55am    
But I'm unable to see anything here
shakil0304003 7-Jun-11 5:46am    
Use google 1st!!!

1 solution

Write below function of javascript in your parent window. We will call it later from the child.
XML
<script language="javascript" type="text/javascript">
function ParentWindowFunction()
{
    alert(‘Hi, At least someone has called me from the child window’);
    return false;
}
</script>

Write the below code in your child window
XML
<script language="javascript" type="text/javascript">
function CallParentWindowFunction()
{
    window.opener.ParentWindowFunction();
    return false;
}
</script>

You can call above function from a button click event like
XML
<input type="button"  name="btn1″ value="Call Parent Window Function" onclick="javascript:return CallParentWindowFunction();"/>

That’s it. Now by clicking on this child window’s button you can call a function resides in parent window.
 
Share this answer
 
v2

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