Preventing unload .

  • Thread starter Nithya Venkatachalam
  • Start date
N

Nithya Venkatachalam

Hi,

How to stop unloading a page in the event handler called during
onUnload?

onUnload=unloadhandler();

function unloadhandler()
{
if(!confirm("message"))
{
I want something to be done which prevents the page from
unloading and returns to the same page as 'back' functionality
}

}
 
H

Hal Rosser

So you want the user to have to close the browser to get away from your site
?
They will love that! and will never return.
 
J

Jasper Bryant-Greene

Nithya said:
Hi,

How to stop unloading a page in the event handler called during
onUnload?

onUnload=unloadhandler();

function unloadhandler()
{
if(!confirm("message"))
{
I want something to be done which prevents the page from
unloading and returns to the same page as 'back' functionality
}

}

Ignoring the fact that this is a very bad idea and an easy way to piss
users off, have you tried simply making unloadhandler() return FALSE?
 
R

Randy Webb

Andrew said:
(guest)
I want a different page, ..no, *site*.

BTW - Do not set follow-ups by email Nithya,
this is not your personal 'help-desk', it is
a *discussion* *forum*!

Does Google allow setting the follow-up? I have never posted from
groups.google so I am curious.
 
M

Michael Winter

Nithya Venkatachalam wrote:

[trying to stop unload]

I have a distinct feeling of déjà vu here. Oh yes. That's because you
already posted this question (twice).
Ignoring the fact that this is a very bad idea and an easy way to piss
users off, have you tried simply making unloadhandler() return FALSE?

That won't work. The unload event can't be cancelled (thank goodness).
Besides, my browser doesn't fire the event at all when I close a tab, or
the browser itself. Trying to rely on this approach is a very bad idea.

Randy Webb does propose another approach in the original incarnation of
this thread (posted yesterday), which will work in IE and Mozilla.

Mike
 
R

R. van Laake

Don't be such a pisser, beforehand assuming the guy has malintentions.

I have exactly the same question and my motive for it is that I am building
a web *application* for the employess at the office. They shouldn't be able
to shut the application with Alt-F4 for many good business-reasons (like
logging, making sure their work is properly saved, etc.)

Ray
 

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,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top