浏览器关闭时如何更新数据库表。 [英] how to update database table when browser close.

查看:86
本文介绍了浏览器关闭时如何更新数据库表。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在浏览器关闭时更新数据库表。

how to update database table when browser close.

推荐答案

肯定没有办法做到这一点。



浏览器关闭的时间(以及如何)不在你的控制范围内。

由于系统崩溃,浏览器可能会关闭 - 即使你有浏览器运行的代码关闭,它不会执行。
There is simply no way to do this with surety.

When (and how) the browser closes is not in your control.
The browser could close because of a system crash - and even if you had code that would run when your browser closes, it would not execute.


这些链接可以帮助你

如何知道浏览器在c#中关闭 [ ^ ]

检测浏览器已关闭 [ ^ ]
These links mat help you
How to know Browser is closed in c#[^]
Detect Browser is closed[^]


查看此示例: -

see this example:-
<script type="text/javascript">
     function unload()
    {
        if (document.getElementById('HdnisSave').value =='0')
        {
            event.returnValue = "UNSAVED DATA WILL BE LOST!!";
        }
    }
</script>
<body  onbeforeunload="unload()" >
<asp:HiddenField ID="HdnisSave" runat="server" Value="0" />




当您的浏览器关闭时,
将通知您浏览器已关闭,您的数据将保存,并提供一些选项,例如保留此页面或保留此页面。

i希望它会有所帮助你保存数据时的
比设置隐藏字段值= 1。



when your browser close than this js will inform you that your browser is closed and your data will be unsaved and give you some option like leave this or stay this page.
i hope it will help you.
when you save data than set hidden field value =1.


这篇关于浏览器关闭时如何更新数据库表。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆