JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 31st, 2003, 04:37 PM
velocityX velocityX is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 72 velocityX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 36 sec
Reputation Power: 15
Send a message via AIM to velocityX
Question Auto refresh parent window after closing popup

Does anyone know the code for, If you close the popup window then the parent window that made the popup will refresh?

Reply With Quote
  #2  
Old August 31st, 2003, 05:15 PM
EiSa EiSa is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Norway
Posts: 184 EiSa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 22 m 24 sec
Reputation Power: 15
Here is a code that refresh parent window and closes the the popup in one operation.

Code:
<script language="JavaScript">
<!--
function refreshParent() {
  window.opener.location.href = window.opener.location.href;

  if (window.opener.progressWindow)
		
 {
    window.opener.progressWindow.close()
  }
  window.close();
}
//-->
</script>

Reply With Quote
  #3  
Old September 1st, 2003, 04:06 AM
sumicooldude sumicooldude is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 48 sumicooldude User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 59 sec
Reputation Power: 15
try this

well i am using this script on my popup.asp page

<body onunload="opener.location=('page.asp')">


where "page.asp" is the page that you want to be refreshed when ur popup window closes.


hope this will prove helpful

regards
Sumeet

Reply With Quote
  #4  
Old September 1st, 2003, 07:25 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Posts: 2,056 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 44 m 22 sec
Reputation Power: 0
To reload a window you can use the location method reload(). This method is handy because you don't need to know the name of the window you wish to refresh.

e.g. window.opener.location.reload()

Reply With Quote
  #5  
Old June 9th, 2004, 04:57 AM
sivaraj2003 sivaraj2003 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 1 sivaraj2003 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by EiSa
Here is a code that refresh parent window and closes the the popup in one operation.

Code:
<script language="JavaScript">
<!--
function refreshParent() {
  window.opener.location.href = window.opener.location.href;

  if (window.opener.progressWindow)
		
 {
    window.opener.progressWindow.close()
  }
  window.close();
}
//-->
</script>

It works fine!

Is there any way that the data in the parent page is not lost while reloading?

Expecting this solution for ASP.Net.

Reply With Quote
  #6  
Old June 15th, 2004, 06:09 PM
fivezerotwo fivezerotwo is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 1 fivezerotwo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
you can assign the variables to hidden fields, then on the refresh assign them back out. or just use IsPostBack.

Reply With Quote
  #7  
Old November 18th, 2004, 12:28 PM
savageideas savageideas is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 1 savageideas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question

I'm new to using JavaScript so my question is in regards to where this code is to be placed: on the parent or child page? Also, is there a function call that needs to be made to initiate the script?

Reply With Quote
  #8  
Old November 1st, 2005, 02:45 PM
snowgurl snowgurl is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2005
Location: Bozeman, MT
Posts: 2 snowgurl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 49 m 29 sec
Reputation Power: 0
I've been using this script on a site for about a year but about a month ago it stopped working. It will close the pop-up but not refresh the parent. I've tried it in a bunch of different browsers and platforms but it won't work anywhere. Does anyone know what might have happened? It's really strange. The parent page will just churn for a while like it's trying to do something but it never gets anywhere. It seems like it's trying to refresh, anyway, and there's some connection between the pages.

Any suggestions would be appreciated.

Reply With Quote
  #9  
Old November 2nd, 2005, 07:41 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 17
snowgurl:
What does your code look like?
they may something strange sopping it from working.

EiSa:
I realize this post is very old and chances are none of the original posters still read this thread... but I have to get this off my chest =)

A function named "refreshParent" shouldn't close the parent as well... I would deem that out of scope of refreshing. Perhaps rename the function to "closeRefreshParent" or something...

Yes the example should work as given and perhaps I'm being picky about the name he/she chose for the function... This is a general complaint to common programming pratices and not a direct bashing of EiSa's example.

There, I said it =)

Reply With Quote
  #10  
Old December 21st, 2005, 01:35 PM
snowgurl snowgurl is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2005
Location: Bozeman, MT
Posts: 2 snowgurl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 49 m 29 sec
Reputation Power: 0
Sorry I didn't see your reply sooner -- I didn't check back here to see if someone answered until now.

I just today figured out what was wrong. I had the correct code on the popup page -- just as you have here. The problem was on my link to the popup. I had "#" in there for the link for the javascript calling the popup. So, when it was trying to refresh it was looking for update?MemberID=647# -- and it couldn't resolve it.

I put in "javascript: void(0)" for the link and it's working fine now. It is strange, though, that it worked for a long time with the "#" in there but all of a sudden stopped. Goofy. Oh, well ... it works now.

I hope this helps someone else and saves them from going crazy some day.

Reply With Quote
  #11  
Old December 22nd, 2005, 08:43 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 17
Good stuff, thanks for the update!
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter!
DevArticles Forum Moderator

"The net is a waste of time, and that's exactly what's right about it." -- William Gibson

Reply With Quote
  #12  
Old January 9th, 2008, 01:42 PM
TooSpecial TooSpecial is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 2 TooSpecial User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 50 sec
Reputation Power: 0
Quote:
Originally Posted by fivezerotwo
you can assign the variables to hidden fields, then on the refresh assign them back out. or just use IsPostBack.

Hi,
i have almost the same case,
and i assigned the variables using javascript, but on refresh i lost them, and i have to keep if !ispostback
how can i assign them again..
shall i do it just after the refresh ?
does it work this way..
thanks

Reply With Quote
  #13  
Old January 9th, 2008, 01:46 PM
TooSpecial TooSpecial is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 2 TooSpecial User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 50 sec
Reputation Power: 0
Quote:
Originally Posted by stumpy
To reload a window you can use the location method reload(). This method is handy because you don't need to know the name of the window you wish to refresh.

e.g. window.opener.location.reload()


but if you are working on a master page, that has content place holder you gonna have to refresh your page using
window.location.href = window.location.href

Reply With Quote
  #14  
Old January 24th, 2008, 07:30 AM
indnajns indnajns is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 1 indnajns User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 19 sec
Reputation Power: 0
Thanks!

Thank you for this thread! Unintentionally and years after the original post, you all solved my problem. And not like you would expect, either. I also had working code that just "quit". I was about to implement one of the answers on here when I found a line in my code I had forgotten about that was causing the problem. Oh Thank You! I was getting SO tired of staring at non-working code with no clue what was going on. You just don't know how tired. Thanks.

Reply With Quote
  #15  
Old August 15th, 2008, 08:10 AM
enisonica enisonica is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2008
Posts: 1 enisonica User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 54 sec
Reputation Power: 0
Quote:
Originally Posted by TooSpecial
but if you are working on a master page, that has content place holder you gonna have to refresh your page using
window.location.href = window.location.href


But this doesn't refresh whole page, if it is contained with few frames.
In my case, from master page (index.php) that is cntained with 3 frames, from one frame it is opened a popup window. When this popup window closes, it refresh only that frame, not the whole page.
how can i make him reload whole page index.php?
thx

Reply With Quote
  #16  
Old November 24th, 2008, 05:10 AM
vestanbul vestanbul is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2008
Posts: 1 vestanbul User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 5 sec
Reputation Power: 0
Quote:
Originally Posted by sumicooldude
<body onunload="opener.location=('page.asp')">


I have solved my problem by using this. Thank You...

Reply With Quote
  #17  
Old December 26th, 2008, 05:05 AM
kamleshg kamleshg is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2008
Posts: 1 kamleshg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 20 sec
Reputation Power: 0
Refresh the parent window when popup get closed

As per best of my knowledge :

Best way to refresh the parent window after closing the popup window is : just call following javascript

< script > window. operner. location. reload(); < / script >

This method is really easy because you don't need to get the the name of the window you need to refresh.

Thanks


Kamleshkumar Gujarathi.
kamlesh.gujarathi at indiatimes dot com
Success Needs Different Approch

Reply With Quote
  #18  
Old April 28th, 2010, 09:17 AM
srhrkrishna srhrkrishna is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2010
Posts: 1 srhrkrishna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 29 sec
Reputation Power: 0
Sr33

Hi, I am calling the popup window by using Page.RegisterStartupScript() in code behind file.

When I use
<body onunload="opener.location=('page.asp')">

the javascript error shows that
"opener.location is either null or not an object"

Can any one help with this.
Thanks in advance.

Reply With Quote
  #19  
Old November 7th, 2012, 09:51 AM
rkrockr rkrockr is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 1 rkrockr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 30 sec
Reputation Power: 0
How to refresh parent window when child window is closed using JavaScript in Asp.Net

To implement this functionality first create one new website and open Default.aspx page and write the following code.

<head runat="server">
<title>Main Form</title>

<script type="text/javascript">
function OpenChildWindow() {
// To open a new browser window, use the window.open() method.
window.open('ChildPage.aspx', null, 'height=300, width=300, status=yes, toolbar=no, menubar=no, location=center, scrollbar=no');
}
</script>

</head>
<body>
<form id="form1" runat="server">
<div align="center">
<p>
Click on button to open new window</p>
<asp:Label ID="lbltext" runat="server" />
<asp:Button ID="btnClick" runat="server" Text="Open Child Window"OnClientClick="OpenChildWindow()" />
</div>
</form>
</body>
</html>

In code behind Default.aspx.cs add this code:
protected void Page_Load(object sender, EventArgs e)
{
// To Display Current Date:
lbltext.Text = DateTime.Now.ToString();
}

Now add new webform named ChildPage.aspx:






<script type="text/javascript">
function closechildwindow() {
window.opener.document.location.href = 'default.aspx';
window.close();
}
</script>

</head>

<body onunload="closechildwindow()">
<form id="form1" runat="server">
<div>
<p>
Now close the child window and notice that parent page get changed</p>
</div>
</form>
</body>
</html>


Hope this will help you out.

Reply With Quote
  #20  
Old November 29th, 2012, 07:10 PM
Chris2tina Chris2tina is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 6 Chris2tina User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m
Reputation Power: 0
I hope this will prove helpful...


Reply With Quote
  #21  
Old October 23rd, 2013, 12:28 PM
vipin4u vipin4u is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2013
Posts: 8 vipin4u User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 29 m 10 sec
Reputation Power: 0
Quote:
Originally Posted by rkrockr
To implement this functionality first create one new website and open Default.aspx page and write the following code.

<head runat="server">
<title>Main Form</title>

<script type="text/javascript">
function OpenChildWindow() {
// To open a new browser window, use the window.open() method.
window.open('ChildPage.aspx', null, 'height=300, width=300, status=yes, toolbar=no, menubar=no, location=center, scrollbar=no');
}
</script>

</head>
<body>
<form id="form1" runat="server">
<div align="center">
<p>
Click on button to open new window</p>
<asp:Label ID="lbltext" runat="server" />
<asp:Button ID="btnClick" runat="server" Text="Open Child Window"OnClientClick="OpenChildWindow()" />
</div>
</form>
</body>
</html>

In code behind Default.aspx.cs add this code:
protected void Page_Load(object sender, EventArgs e)
{
// To Display Current Date:
lbltext.Text = DateTime.Now.ToString();
}

Now add new webform named ChildPage.aspx:






<script type="text/javascript">
function closechildwindow() {
window.opener.document.location.href = 'default.aspx';
window.close();
}
</script>

</head>

<body onunload="closechildwindow()">
<form id="form1" runat="server">
<div>
<p>
Now close the child window and notice that parent page get changed</p>
</div>
</form>
</body>
</html>


Hope this will help you out.


Nice one. Like it

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Auto refresh parent window after closing popup


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap