"OnClose" window event

K

Kamyk

Hello all!

I know that in HTML there is no such event, but is it possible to make event
on close a window. If so, please write me example how to do it.

Thank you in advance
Marcin from Poland
 
S

Steve Pugh

Kamyk said:
I know that in HTML there is no such event, but is it possible to make event
on close a window. If so, please write me example how to do it.

What do you want to do and why? If we know more details we may be able
to suggest alternatives.

There's onUnload but that get's triggered when a link is followed and
as it's often misused for nefarious purposes I believe some browsers
are starting to give users the ability to switch it off.

If the window in question was created by another window the the
creating window can check for the existance of the created window.
Hence you could run a check periodically, or whenever the creating
window recieves focus and perform an action then if the created window
no longer exists. Of course that's no good if the creating window is
closed first.

Steve
 
K

Kamyk

I know that in HTML there is no such event, but is it possible to make
eventI want to delete one value from one column from the database using a SQL
query
after clicking "x" on the window. So how to link it with a event. Is it
possible?

Marcin from Poland
 
A

Adrienne

I want to delete one value from one column from the database using a SQL
query
after clicking "x" on the window. So how to link it with a event. Is it
possible?

Marcin from Poland

That's very BAD idea. If there is no javascript available, you will not
have an event. If you do have javascript, and the window is not closed,
how is your script going to fire? You need to rethink your application.
 
D

David Dorward

Kamyk said:
I want to delete one value from one column from the database using a SQL
query after clicking "x" on the window. So how to link it with a event. Is
it possible?

Not really, no. Certainly not with any degree of reliability.
 
K

Kamyk

I thought that my idea is good, because for example I will have a button
"Log off" which will delete
me a value from a record after clicking on. But what about the situation
when somebody will not
click on the button "log off" and he close the window. In that situation the
value which I want to delete
will be available in the record in the database.

Please verify my thinking.

Marcin from Poland
 
D

David Dorward

Kamyk said:
what about the situation when somebody will not click on the button "log
off" and he close the window. In that situation the value which I want to
delete will be available in the record in the database.

Do the same as everybody else - accept that HTTP is a stateless protocol and
have a program that runs on a timer and cleans out sessions that have been
inactive for $too_long seconds.
 
K

Kamyk

Do the same as everybody else - accept that HTTP is a stateless protocol
and
have a program that runs on a timer and cleans out sessions that have been
inactive for $too_long seconds.

Could you be so kind and give me the code example, because I`m a the
beginner
of HTML and Javascript. I would like to do web page using ASP language
(vbscript).

Thank you in advance
Marcin
 
N

Noozer

Kamyk said:
I thought that my idea is good, because for example I will have a button
"Log off" which will delete
me a value from a record after clicking on. But what about the situation
when somebody will not
click on the button "log off" and he close the window. In that situation the
value which I want to delete
will be available in the record in the database.

Please verify my thinking.

Remember that webpages are "one way"... data comes to the client and the
client does something. The only way for the client to communicate back to
the server is to either pass values when loading the next page or save
cookies before loading the next page. The next page will then act on the
data it recieves once it's loaded into the client machine. Using ASP you can
have the server perform some actions on the passed data (but not cookies)
during execution on the server. You can NEVER count on the next page
actually being loaded or that the user will close the page or browser
properly.

As long as you keep the above in mind you should be able to develop a proper
program flow.
 
A

Adrienne

Could you be so kind and give me the code example, because I`m a the
beginner
of HTML and Javascript. I would like to do web page using ASP language
(vbscript).

Thank you in advance
Marcin

You should really post this to an ASP group,
microsoft.public.inetserve.asp.general would be a good idea, or Google in
the group in the past month and you might find what you're looking for.
 
D

David Dorward

Kamyk said:
Could you be so kind and give me the code example, because I`m a the
beginner of HTML and Javascript. I would like to do web page using ASP
language (vbscript).

Its not an HTML or JavaScript issue, and I don't do VBScript. Doesn't ASP
have some prewritten session handling libraries? Most languages do.
 
K

Kamyk

Its not an HTML or JavaScript issue, and I don't do VBScript. Doesn't ASP
have some prewritten session handling libraries? Most languages do.

Yes, ASP does have session handling libraries, but I don`t know how to use
them
to solve my problem. Maybe I have not got a good idea, because I wanted to
insert a user id into a table using SQL query, and after logging him off, I
wanted
delete this user id from the table. After such procedure I will have a list
of
currently logged in users. I don`t know how to use sessions to receive the
same
data (currently logged users).

Please help me, if you can

Marcin
 
N

Norbtach

There is an event "onunload".
Try this:
<body onunload="JavaScript: . . . . . . >
Robert.
 
A

Adrienne

Yes, ASP does have session handling libraries, but I don`t know how to
use them
to solve my problem. Maybe I have not got a good idea, because I wanted
to insert a user id into a table using SQL query, and after logging him
off, I wanted
delete this user id from the table. After such procedure I will have a
list of
currently logged in users. I don`t know how to use sessions to receive
the same
data (currently logged users).

Please help me, if you can

Marcin

You're going to face some other problems as well. Session variables across
pages will not work if the user does not accept session cookies. The only
way to reliably do it is either with hidden input elements or querystring.

What you could possibly do, however, is do a clean up after a certain
amount of time, like a if a person has been logged on for more than 24
hours.

IIRC there was some discussion on this in
microsoft.public.inetserver.asp.general I few weeks ago. You might want to
Google over there to see if anything strikes your fancy.
 
N

Norbtach

There is an event "onunload".
Try this:
<body onunload="JavaScript: . . . . . . >
Robert.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top