ultraman Posted November 9, 2004 Posted November 9, 2004 Hi all ! Is there a way to catch the unload event when someone close the IE window with the "X" ? I tried JS in Body onunload but it's not working. I just want to ask a confirmation message before he close the window. If the answer is yes, just close the window, otherwise cancel the close event. Is it possible ? Quote Now go on, boy, and pay attention. Because if you do, someday, you may achieve something that we Simpsons have dreamed about for generations: You may outsmart someone! --Homer Simpson
eramgarden Posted November 9, 2004 Posted November 9, 2004 Maybe have a "close" button. Then if users click that, popup a msg if they want to close... My JS looks like this: <script language="javascript"> function confirm_delete() { if (confirm("Are you sure you want to delete the Activity?")==true) return true; else return false; } </script> My button looks like this: <asp:Button Runat="server" Font-Bold="True" BackColor="Red" ID="btnDelete" CommandName="Delete" Text="Delete Activity"></asp:Button> Then in the code behind: If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then Dim _myButton As Button = CType(e.Item.FindControl("btnDelete"), Button) Dim test = _myButton.Text _myButton.Attributes.Add("onclick", "return confirm_delete();") End If Quote
ultraman Posted November 9, 2004 Author Posted November 9, 2004 Thanks eramgarden, I know this would work. But still, it won't prevent the user from using the "X".... Quote Now go on, boy, and pay attention. Because if you do, someday, you may achieve something that we Simpsons have dreamed about for generations: You may outsmart someone! --Homer Simpson
eramgarden Posted November 9, 2004 Posted November 9, 2004 Wonder if there's a way to detect that.. Quote
*Gurus* Derek Stone Posted November 10, 2004 *Gurus* Posted November 10, 2004 Use the onunload and onbeforeunload events. Quote Posting Guidelines
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.