检测vb.net浏览器关闭事件 [英] detect browser close events in vb.net
本文介绍了检测vb.net浏览器关闭事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个网页,看起来像:
I am having a Web Page that looks like:
<%@ Page Language="vb" AutoEventWireup="false" MasterPageFile = "~/Master11.master" CodeBehind="test7.aspx.vb" Inherits="MyApp.test7" %>
<%@ MasterType TypeName = "ASP.sample_template_master" %>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContent1" runat="server">
</asp:Content>
当用户关闭浏览器,我想如果用户想要退出前保存显示一个确认框。
When the user closes the browser, I want to display a confirm box if the user wants to save before exit.
如果他说是,那么我想保存数据库中的信息,并关闭浏览器一样,我只是关闭浏览器。
If he says yes, then I wish to save the information in database and close the browser else I just close the browser.
我看了MSDN论坛,但所有我发现了窗口关闭事件,我无法适用于此。
I read msdn forums but all I found was window closing event which I was not able to apply here.
请帮忙。
谢谢,
krum_cho。
Thanks, krum_cho.
推荐答案
请尝试使用下面的JavaScript语句。
Try using the following JavaScript statement.
window.onbeforeunload = function () {
if ((window.event.clientX < 0) || (window.event.clientY < 0) || (window.event.clientX < -80)) {
alert("Child window is closing...");
}
};
这篇关于检测vb.net浏览器关闭事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文