Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Hi,
 
How to refresh the page when i close the popup window..?
 

see my code
-------------
 
<a href="#" onclick="window.close();" class="Content">Close Window</a>
 
I want, when i close the popup window, immediately the parent form should get refresh or reload..
 
How to do this...?
Posted 28-Jul-11 3:17am
gani77871.3K
Edited 28-Jul-11 4:04am
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

There are several ways but one simple way could be
function closeandrefresh(){
  opener.location.href = opener.location.href;
  window.close(); 
}
 
 
And update your link as
 
<a href="#" onclick="closeandrefresh();" class="Content">Close Window</a>
  Permalink  
Comments
EdMan196 at 28-Jul-11 10:26am
   
Good answer, much simpler than mine. I hadn't thought about using the opener variable. Would suggest you tell the user how to attach this method to the closed event as most user's prefer to click the red X button on popup windows rather than Close links. I would also question how reliable this is in all browsers though? Namely IE never seems to conform. Would advise OP to check all javascript (inc. this) for cross-browser compatibility and also say that Chrome and Firefox are best to develop on as they are the most standards compliant. My 5+, Ed :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Dear it is possible through AJAX............
  Permalink  
Comments
gani7787 at 28-Jul-11 9:29am
   
Can you tell me the steps...?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

You can use a recursive function in the parent window to wait for the popup to close. E.g.
 
<html>
<head>
<script type="text/javascript">
var generator = null;
function show_prompt()
{
    //Open a popup and store the handler in a var named generator
    generator = window.open("", "New Popup", "width=400, height=400");
    //Add some html to the new window
    generator.document.write("<html><head><title>Test</title></head><body>");
    generator.document.write("<p><a href=\"javascript:self.close()\"> Close</a></p>");
    generator.document.write("</body></html>");
    generator.document.close();
    generator.focus();
    
    //The crucial line! Start the recursive function that will poll the new popup window until it's closed. 
    WaitForClose();
}
function WaitForClose()
{
    //Check to see if the popup has been closed
    if(!generator.closed)
    {
        //If not, recall this function - the recursion
        setTimeout("WaitForClose()", 500);
    }
    else
    {
        //If popup has been closed, call the PopupClosed funtion
        PopupClosed();
    }
}
function PopupClosed()
{
    //Do something here!
    alert("x");
}
</script>
</head>
<body>
<input type="button" onclick="show_prompt()" value="Show prompt box" />
</body>
</html>
 

 
Hope this helps,
 
Ed Smile | :)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

function refreshParent() {
  window.opener.location.href = window.opener.location.href;
  if (window.opener.progressWindow)
 {
    window.opener.progressWindow.close()
  }
  window.close();
}
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 545
1 OriginalGriff 498
2 sanket saxena 330
3 Abhinav S 280
4 thatraja 275
0 Sergey Alexandrovich Kryukov 8,372
1 OriginalGriff 4,830
2 Peter Leow 3,784
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web04 | 2.8.140415.2 | Last Updated 28 Jul 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid