PDA

View Full Version : Need a confirmation to leave page script



Falah
10-29-2009, 12:13 AM
I need a DHTML script that pops up when someone is trying to leave the window (kind of like those light boxes when you zoom in on an image) for an email client, but I don't want it to be a JavaScript alert. Anyone have the script or know how to do this?

I'd be extremely appreciative as I've been trying for ages now.

Nile
10-29-2009, 02:25 PM
I'm sorry, I don't think its possible. But there is a Javascript way if you like:


<script type="text/javascript">
window.onbeforeunload = function(){ return "Are you sure you want to leave the page?"; }
</script>

Falah
10-29-2009, 04:48 PM
I'm sorry, I don't think its possible. But there is a Javascript way if you like:


<script type="text/javascript">
window.onbeforeunload = function(){ return "Are you sure you want to leave the page?"; }
</script>


I have loads different ways to do it with javascript but this is for a client who wants a popup. How about a javascript event that triggers a DHTML one?

Nile
10-29-2009, 05:07 PM
Don't think so... Sorry.

bluewalrus
10-29-2009, 05:52 PM
Not sure if this is the same or different havent looked at it in a while

http://www.dynamicdrive.com/forums/showthread.php?t=41738&highlight=leave

Falah
10-29-2009, 08:13 PM
Not sure if this is the same or different havent looked at it in a while

http://www.dynamicdrive.com/forums/showthread.php?t=41738&highlight=leave

kind of, but you know how those pages have the chat that pops up also with a person saying "Hi, how can I help you?" or whatever also when the javascript message pops up.

I want something that does that. If I find a link to one again I'll post it.

Nile
10-29-2009, 08:48 PM
Bluewalrus, I already suggested that... And what I think you're talking about is a JS Modal Window, preferably something like this (http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm). Correct?

bluewalrus
10-29-2009, 09:21 PM
Yea something like the window one close window but in an alert so it's outside of the window. I didn't have time to test that code i post the link to. I thought when i tested it before it had a confirm in an alert type window though.

Nile
10-29-2009, 09:41 PM
I don't understand bluewalrus. Your code was fine, it just wasn't what he was looking for. I was trying to say that I already suggested the code you provided.

jscheuer1
10-30-2009, 05:19 AM
Personally if some web site warned me when I was leaving it, it would have to be a really good web site for me to ever bother returning to it. And I think most people feel this way.