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
0 Sergey Alexandrovich Kryukov 458
1 OriginalGriff 294
2 George Jonsson 258
3 CPallini 160
4 Shemeemsha RA 140
0 OriginalGriff 5,985
1 Sergey Alexandrovich Kryukov 5,341
2 CPallini 4,760
3 George Jonsson 3,400
4 Gihan Liyanage 2,522


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100