473,796 Members | 2,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.l ocation
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 8568
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.clos ed )
{
// 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
13605
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. 3) but it should not open the popup window till the user is on same website. we have tried lot of combinations but till date nothing there.
7
5597
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 button on another form (frmEmpList) which has a list box that contains the names of all employees. When a name is selected in the list box and the button is clicked, frmVacationWeeks opens and is filtered using the following: ". IN (" & Left(strSQL,...
5
3091
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 accomplishing this it in forms using the forms properties. However the close button for Access program itself is always there in the upper right hand corner. How do I hide or disable it? I have played around with options and startup options, looked...
1
4627
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 to do that in ASP.NET with VB code? Unload Me 'does not work either WebForm1.Exit() 'also does not do the trick either
1
1962
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 engaged. When the owner closes one of his child windows, I want to update the master window. I understand "reasonably" well how to go about this. The master window launches the children, and maintains an associative array to keep track of each one....
3
1088
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 connection opens/closes 2 times. I think this is not normally and now I added to my page class a 'private SqlConnection MyConn'. Both above 2 handlers
1
1401
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 how can I call the log sub and write a closed program log entry ? 'Add any initialization after the InitializeComponent() call CreateLFile() Dim myear As String = Date.Now.Year.ToString
3
1868
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 noticed that the call pass to the server is not consistent. Q:Is there a better way of logging the time user spent on my page before leaving it?
13
5657
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
9528
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10455
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10228
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10173
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7547
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.