473,406 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

call a function on page close NOT unload

Hi,

I have a page - page1 which opens a window1 where users can look at
tasks, in window1 users can click and open window2 where they can
create new tasks
I want to refresh window1 when window2 closes
and refresh page1 when window 1 closes
Currently i am calling a javascript function on unload which refreshes
window.opener.location
the problem i am having is that when window2 closes it unloads itself
and calls refresh on window1 which unloads itself on refresh and hence
refreshes page1
I do not want to refresh page1 when window2 closes only if window1
closes. I hope this makes sense
Is there anyway i can differenciate between unload and a page close?
because unload gets called on refresh also, and i would like to only
take actions when a page closes not wen it unloads
thanks
B

Jul 5 '06 #1
1 8543
Hi,

Donkey Cart Racer wrote:
Hi,
[snip]
Is there anyway i can differenciate between unload and a page close?
because unload gets called on refresh also, and i would like to only
take actions when a page closes not wen it unloads
thanks
B
No, there is no way to differentiate between an onunload even when the
page refreshes, or when it gets closed. For the page, it's the same.

However, if window1 has a reference on window2, you can check if the
window is closed, and take appropriate action.

You can get a reference on another window either when you open it:

var myWindow2 = window.open( [url], [NAME], [FEATURES] );

and then:

if ( !myWindow2.closed )
{
// Refresh page
}

If window1 didn't open window2, and if you know window2's name, you can
use window.open to gain a reference on the already opened window:

var myWindow2 = window.open( "", [NAME], "" );

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Jul 5 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: connoisseur.infotech | last post by:
We have a website we need to open popup under following conditions 1) When user close the browser either via X button or alt + f4, file -> Close 2) when he changes URL and goes to some other site....
7
by: jdph40 | last post by:
I posted this problem previously and received excellent help from Wayne Morgan. However, I still have an unanswered question. My form (frmVacationWeeks) is opened from the OnClick event of a...
5
by: Nick250 | last post by:
I have a simple app that I created for our Real Estate office using Access 2000 and it is working fine except for on thing. I need to keep the close button hidden from the users. No problem...
1
by: ae | last post by:
Provided is some basic code VB.Net for applications, but I am trying to find the best method to destroy an asp page, similar to EXIT if i were to go to IE press File and EXIT. Does anyone know how...
1
by: Bill Borg | last post by:
Hello all, Simple chat app, where the site owner has a master window with all requests for chat, status of each room, etc., and child windows for each separate chat in which the owner is...
3
by: Tumurbaatar S. | last post by:
Hi! The situation is: 1. In Page_Load, I open a database connection which is closed on handler finish. 2. In Button_Click, I do same thing again as above. So during one request, a db...
1
by: Michael R. Pierotti | last post by:
I have a app I have written that when the program is opened it logs out to a logfile. What I can't figure out is that "X" button at the top. If a user clicks on that instead of my menu item close...
3
by: shlomi.schwartz | last post by:
Hi all, I'm trying to create a server side log, that will show how much time a user was present on my web page. I tried using onUnload and onBeforeUnload to do an http call to the server. I've...
13
by: Gouri.Mahajan7 | last post by:
Hello, Can anybody please tell me how to trap the browser close event. when that is fired I want to call the web method. Thanks in advance. Regards, Gouri.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.