?
Solved

Refersh parent window when child window closes in JAva script

Posted on 2011-04-18
5
Medium Priority
?
406 Views
Last Modified: 2012-05-11
Need to refersh parent window when child window is closed in C#/JAva scripts
0
Comment
Question by:nkc1112
5 Comments
 
LVL 3

Accepted Solution

by:
wuyinzhi earned 400 total points
ID: 35421430
in JavaScript maybe like this:

window.close();
if (window.opener && !window.opener.closed) {
window.opener.location.reload();
}
0
 
LVL 2

Assisted Solution

by:Suraj_Mathew
Suraj_Mathew earned 400 total points
ID: 35421528
The above posted answer is correct , but need to keep the statement "window.close();" as the last statement...right......

Otherwise , the window will get closed initially and i assume the code will exit without executing the statement below......  am i correct...???
0
 
LVL 10

Assisted Solution

by:khan_webguru
khan_webguru earned 800 total points
ID: 35421974
You can use this method just call on child window close

 
<script language = javascript>
function refreshparent()
{
if(!window.opener.location)
window.opener.location = self;
window.opener.location.reload();
window.close();
}
</script>

Open in new window


Above method will close child window too.

Hope that might help you.

Thanks,

Asif Ahmed Khan
0
 
LVL 10

Assisted Solution

by:khan_webguru
khan_webguru earned 800 total points
ID: 35421992
LIVE DEMO

You can see the live demo and code here
http://www.plus2net.com/javascript_tutorial/window-refreshing.php

 
<SCRIPT language=JavaScript>

function win(){
window.opener.location.href="parentWindow.html";
self.close();

}
</SCRIPT>

Open in new window


Hope That might help you.

Thanks,

Asif Ahmed Khan
0
 
LVL 6

Assisted Solution

by:havj123
havj123 earned 400 total points
ID: 35422941
You could add at the end of the button submit click event the below code

ASP.NET 2.0

Page.ClientScript.RegisterStartUpScript(this.GetType(),"close","<script language=javascript>window.opener.location.reload(true);self.close();</script>");

ASP.NET 1.X

Page.RegisterStartUpScript("close","<script language=javascript>window.opener.location.reload(true);self.close();</script>");
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question