我正在使用jQueryMobile和phoneGap作爲跨設備的移動應用程序。我使用html 5本地存儲來保存用戶處理的記錄。要關閉應用程序的哪個事件?
我不知道在應用程序關閉前要捕獲哪個phoneGap事件,因此我可以確保在關閉完成之前保存數據。
基於naughtur的建議,我嘗試了卸載和beforeunload事件,他們都沒有在應用程序關閉期間被解僱。以下是我的代碼剪斷:
function persistTasks(){
alert ("is unloading the app");
offlineTasklist.set("tasks", tasklist);
}
function init() {
document.addEventListener("unload", persistTasks, false);
login();
}
$(document).ready(init);
這很有趣。嘗試卸載並在卸載事件之前回發它們是否工作。如果沒有 - 我們將不得不在電話apis – naugtur 2011-01-13 07:50:44