Server side actions on closing the browser window

S

Santel

Hi,

I would like to do some server side actions while closing the browser
window. I tried with Page_Unload event, but it triggers while loading
the page itself. Anyone please tell me is there any event that triggers
on closing the page?
 
K

Karl Seguin

You pretty much need to hook into a javascript event (like onbeforeunload),
and fire some server side code - either be poping up a window or doing some
ajax.

Karl
 
M

Mark Rae

I would like to do some server side actions while closing the browser
window. I tried with Page_Unload event, but it triggers while loading
the page itself. Anyone please tell me is there any event that triggers
on closing the page?

As Eliyahu says, you can (try to) use the window.unload event, but the
problem here is that not all browsers handle this event in the same way, and
it will (sometimes) fire if the user clicks the Refresh button, which will
probably cause a lot more problems for you...

What are you trying to achieve with this...?
 
L

Laurent Bugnion [MVP]

Hi Mark,

Mark said:
As Eliyahu says, you can (try to) use the window.unload event, but the
problem here is that not all browsers handle this event in the same way, and
it will (sometimes) fire if the user clicks the Refresh button, which will
probably cause a lot more problems for you...

Out of curiosity, in your experience, which browsers do not fire
window.unload when the page is refreshed?

Greetings,
Laurent
 
M

Mark Rae

Out of curiosity, in your experience, which browsers do not fire
window.unload when the page is refreshed?

Safari certainly didn't, though I haven't checked in the latest version...
 
L

Laurent Bugnion [MVP]

Hi,

Mark said:
Safari certainly didn't, though I haven't checked in the latest version...

Interesting. Thanks! That confirms what I thought, that this event is
not reliable.

Greetings,
Laurent
 

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,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top