如果用户关闭浏览器,如何向用户显示警报? [英] How to show alert to user if the user is closing the browser?

查看:90
本文介绍了如果用户关闭浏览器,如何向用户显示警报?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个视频上传网站,用户正在注册和上传他们无限大小的视频,我们遇到的问题是,有些用户并不太聪明,尽管我们正在向他们展示处理图像和我们正在处理的消息您的数据,但他们仍然没有发现视频上传与否,并在上传之前关闭窗口,平均视频大小约为500MB,所以我想在他们尝试时向他们显示您的视频正在处理的警报关闭窗口,我只是想知道有什么办法,我们可以找到用户正在关闭浏览器或选项卡,我搜索它但遗憾的是找不到解决方案,任何人都可以帮助我在这种情况下。

i am working on a video uploading website where users are registering and uploading their video of unlimited size, the problem we are having that some users are not too smart that although we are showing them processing image and a message that we are processing your data, but still they don't find that video got uploaded or not and close the window before it get's uploaded, the average video size is around 500MB, so i thought about showing them an alert that your video is under processing when they try to close the window, i just want to know that is there any way that we can find that user is closing the browser or tab, i searched it but unfortunately couldn't find the solution, can anyone help me out please in this situation.

提前致谢。

推荐答案

试试这个:

Javascript

<script language="JavaScript">
window.onbeforeunload = confirmclose;
function confirmclose(){
choice="Are you sure you want to leave?";
return choice;
}
</script>


Jquery

<script src="jquery-1.7.1.js" type="text/javascript"></script>
<script src="jquery.confirm.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function(){
        function confirmclose() {
                return "Are you sure? you want to close";
        }
        window.onbeforeunload = confirmclose;
    });

这篇关于如果用户关闭浏览器,如何向用户显示警报?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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