$(window).on('beforeunload', function (event) { event.returnValue = "離開頁面將丟失信息"; return "離開頁面將丟失信息!"; });