popup if user wants to close window or enter another url

L

libsfan01

hi all how can u create a conditional alert when the user tries to
close the window or enters another url into the browser? i want to
remind them to save changes.
 
R

Randy Webb

libsfan01 said the following on 8/5/2006 7:11 AM:
hi all how can u create a conditional alert when the user tries to
close the window or enters another url into the browser? i want to
remind them to save changes.

Let them suffer a few times of having to re-enter things and they will
soon start making sure they save it. As for what you think you want to
do, you can't reliably do it.
 
G

Georgi Naumov

It is possible but I strictly recommend you to not use this feature.
You can simply
atach alert function to onunload event handler on BODY tag for example.

<script type="text/javascript">
function myReminder(){
alert("Do you save the changes?");
}
</script>
</head>
<body onunload="myReminder();">

But it is very irritatingli for some users and not good decision about
crossbrowser compatibility.

libsfan01 напиÑа:
 
M

maya

Georgi said:
It is possible but I strictly recommend you to not use this feature.
You can simply
atach alert function to onunload event handler on BODY tag for example.

<script type="text/javascript">
function myReminder(){
alert("Do you save the changes?");
}
</script>
</head>
<body onunload="myReminder();">

But it is very irritatingli for some users and not good decision about
crossbrowser compatibility.

and also very annoying when it gets used for asking you if you want to
bookmark (or set as home pg on browser) the url you're leaving... in
this case I think it would be more justified, maybe do it so users get
reminded only the first few times they visit (can this be done just
client-side? don't remember now...)
 
G

Georgi Naumov

Yes this can be done just client-side. If you want you can use cookie
for store
how many times the user was been ot this web page. Otherwise this way
don't work if the user restrict cookies.
maya напиÑа:
 

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,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top