码迷,mamicode.com
首页 > 其他好文 > 详细

用户关闭浏览器页器,弹出一个提示

时间:2014-08-13 14:53:06      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   io   for   ar   cti   

function PageUnloader() {
    //當用戶退出時是否需要拋出一個提示
    this.UnloadTips = true;

    var _this = this;

    this.Init = function() {
        //當用戶退出時拋出一個提示
        window.onbeforeunload = function(e) { e = window.event || e; return _this.body_onbeforeunload(e); };    
    };
    
    //Unload事件, 當用戶退出時是否需要拋出一個提示
    this.body_onbeforeunload = function(e) {
        if (this.UnloadTips) {
            return "Your project has not been saved and any changes made will be lost!";
        }
    };
}

var oUnloader = new PageUnloader();

 

用户关闭浏览器页器,弹出一个提示,布布扣,bubuko.com

用户关闭浏览器页器,弹出一个提示

标签:style   blog   color   os   io   for   ar   cti   

原文地址:http://www.cnblogs.com/yzenet/p/3910024.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!