Thanks Costas.  But we know about the onbeforeunload event.  The point was
that we need to change the look and feel of the dialog box, AND, allow the
user to save their data and continue closing the window, then abort if
conditions aren't right for the data to be saved.

With the OnBeforeUnload event, yes, we can halt the closing of the form -
with user input.  But if the user says Yes, save the date and close the
form, then a problem is encountered with the data or save, we cannot halt
the close at that point.  At least, we haven't found a way yet.  Plus, we
want to replace the resulting dialog window with one that matches our
look/feel.  Again, no way to do this that we know of yet.

Any other suggestions?  (damn, that sounds dis-respectful, but isn't meant
that way)

Thanks again though.

Shawn Grover

-----Original Message-----
From: Costas Piliotis [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 09, 2002 4:50 PM
To: CF-Talk
Subject: RE: Using JS to intercept/prevent window close via the X
button?


In the body tag, there is a onBeforeUnload event and a onUnload event.

<html>
<script language=Javascript>
function AskFirst() {
        event.returnValue = "This text will be shown in the popup."
}
</script>
<body onbeforeunload="AskFirst();">
This should ask me if I really want to unload the document

</body>
</html>


This way, you shouldn't be stuck with the microsoft implementation of this.
-----Original Message-----
From: Shawn Grover [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 09, 2002 1:58 PM
To: CF-Talk
Subject: OT: Using JS to intercept/prevent window close via the X button?


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



______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to