navigator.notification.confirm('您肯定要退出程序嗎?', showConfirm, '退出程序', '肯定,取消'); function showConfirm(button) { if( button==1 ) { document.removeEventListener("backbutton", eventBackButton, false);//註銷返回鍵 navigator.app.exitApp();//退出app程序 } }
用法:navigator.notification.confirm(message, confirmCallback, [title], [buttonLabels]);app
message:對話框信息。(字符串類型)
confirmCallback:按下按鈕後觸發的回調函數,返回按下按鈕的索引(一、2或3)。(函數類型)
title:對話框標題。(字符串類型)(可選項,默認值爲「Confirm」)
buttonLabels:逗號分隔的按鈕標籤字符串。(字符串類型)(可選項,默認值爲「OK、Cancel」)函數
有上面代碼能夠看出,回到函數接收按鈕返回值經過button便可。spa
轉載請註明:http://www.tea119.comcode