标签: event

  • 退出或刷新页面时提示

    先看代码

    // as my test, Opera do not fire the event
    window.onbeforeunload = function (e) {
        e = e || window.event;
    
        // For IE and Firefox prior to version 4
        if (e) {
            e.returnValue = 'Sure to quit?';
        }
    
        // For Safari and Chrome
        return 'Sure to quit? Data might not be saved.';
    };
    

    (更多…)