473,405 Members | 2,310 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,405 software developers and data experts.

unload for close not refresh

I have a jsp page that updates information as a user enters form
fields. It's part of an AP system where a user can select a category,
and then it refreshes the page, pulling relative info into other form
fields.

The issue we have is that closing the window with the [x] closer does
not clear out buffered info. We have a "close" button that will do
this. I tried doing an "onunload" to call the same function as the
close button, but since the form is reloaded as the user tabs through
fields, it calls the onunload and the window closes.

Does anyone have an idea of how to call the close function when the
window closes, but not when it reloads?

Thanks for any help.

D.
Jul 20 '05 #1
2 3416
On 2 Mar 2004 14:45:23 -0800, DonO <do*@orbandesign.com> wrote:
I have a jsp page that updates information as a user enters form
fields. It's part of an AP system where a user can select a category,
and then it refreshes the page, pulling relative info into other form
fields.

The issue we have is that closing the window with the [x] closer does
not clear out buffered info. We have a "close" button that will do
this. I tried doing an "onunload" to call the same function as the
close button, but since the form is reloaded as the user tabs through
fields, it calls the onunload and the window closes.

Does anyone have an idea of how to call the close function when the
window closes, but not when it reloads?


That cannot be done reliably. onunload is called at different times by
different browsers and some, like Opera, do not fire onunload when the
browser is closed.

Even if it were, it is highly unlikely that anything you do will actually
have an affect as a browser probably won't open a connection to a server
when the user is trying to close it.

Instead, impress upon your users the importance of sending their data
before closing their browser.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #2
Michael Winter <M.******@blueyonder.co.invalid> wrote in message news:<op**************@news-text.blueyonder.co.uk>...
That cannot be done reliably. onunload is called at different times by
different browsers and some, like Opera, do not fire onunload when the
browser is closed.

Even if it were, it is highly unlikely that anything you do will actually
have an affect as a browser probably won't open a connection to a server
when the user is trying to close it.

Instead, impress upon your users the importance of sending their data
before closing their browser.

Mike


Thanks for the reply Mike. Fortunately (I suppose) this is for an
internal project, so I know all my users will be using IE 5.5 or
higher.

I did find something that works, but is really ugly...

I added a new form at the bottom of the page named close_check with a
hidden field with the name "close_me" and default value "1" (true).

I put in a call to a function called "tabCheck()" in all the places
where the tabbing forces the page to reload. This function would set
the "close_me" value to "0" (false) like this:
document.form_check.close_me.value = 1;

My onunload then called a function to which checked the value of
"close_me" if it was "1" it did the close, otherwise, it set the value
back to "1".

So the order of how things happen is:

1) User tabs over fields that reload page
2) "close_me" is set to false
3) onunload function is kicked off
4) Because the close_me value is false, it does NOT close the window

Other scenario:

1) User clicks the [x] to close the window
2) onunload function is kicked off
3) Because the value is set to 1 by default, or at the end of checking
it above, it is true, and the close function is called, just as if
they clicked the "Close" button we have on the page.

So far it seems to work. If anyone has any better ideas, I'm open to
suggestion. For now, with IE this option is ok.

Thanks again,
D.
Jul 20 '05 #3

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

Similar topics

5
by: Harry J. Smith | last post by:
I have written a Visual Basic program that does a long calculation and writes the results to disk as it runs. If I click the Close button the window closes but the program keeps running. How can I...
1
by: salo | last post by:
hi at visual basic 6 i write this to the button1_cl1ck unload form1 form2.show
4
by: V.Boomessh | last post by:
Hai can any one help me on this problem. I am new to VB.NET. I have 2 forms. (form1 and form2) On click of a button in form1 i want to show form2 and unload form1
4
by: Claudia Fong | last post by:
Hi, I have more than one forms in my program, and I would like to for example, in form1, I will call form2 and in form2 it will call form3. But the problem is when I call form2.Show, it does...
3
by: Gauthier Segay | last post by:
Hello, I've an application where all my pages implement a PAGE_CODE string property, this property is stored in HttpContext.Current.Items. In some page, I must persist data in session while...
8
by: Sender | last post by:
In VB6.0 we use Unload Form1 to unload (close) form1 - what shall we have to write to unload a form in VB.Net
2
by: sam | last post by:
I want to know how to unload form / application in VB.Net. In VB 6, the coding is Unload Me but how about VB.Net? VB.Net 1.1 Coding -------------------- Private Sub InitializeComponent()...
1
by: Donkey Cart Racer | last post by:
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...
5
by: =?Utf-8?B?U3RldmVuIFRhbmc=?= | last post by:
It seems that one page XBAP whose Unloaded event never get called, I need put some clearing stuff (I.G stop dispatcher time) when user close browser, it unload event doesn't work, where shall I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.