We have a situation where the user might hit the X button on a window to
close it. We need to prompt the user to save or abort the changes they've
made, and if save is selected but the data is not valid, cancel the close.
I suspect this is not quite possible, but have seen some things that
indicate it might be. I also think we might need to sacrifice some of this
functionality (i.e. if data is not valid, warn the user, but still close the
page...)
The following block of code DOES allow us to prevent closing the window, but
we are stuck with the MS implementation (developing for IE 5.5+) which shows
OK/Cancel buttons, and some extra text in the prompt. This breaks the look
and feel of our app (we have our own confirmation windows we pop up). Also,
it triggers the event if the page is only being reloaded.
<SCRIPT FOR=window EVENT=onbeforeunload>
MyFunction()
</SCRIPT>
<script>
function MyFunction() {
event.returnvalue = "Are you sure?";
}
</script>
So, I'm looking for suggestions on how to go about this. I'm sure someone
has handled this before. Is there some way to do this with hidden frames?
Windows? Is it possible to only do this when a window is in fact being
closed, not reloaded? I think signed scripts might be required, but want to
avoid this if possible.
(if it helps any, our app has a main page, which opens up sub windows, some
modal, as required. These sub windows might open another sub window. But
it is typically the first sub window that we need this functionality on.
Point being, they might close a window, but not be leaving our application.)
TIA.
Shawn Grover
______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists