|
前段时间给大家分享过 jqueryMobile中如何使用phonegap实现退出功能,今天我们看看在 jqmobi中 如何退出我们的应用
- <script type="text/javascript">
- document.addEventListener("deviceready", onDeviceReady, false);
-
- // PhoneGap is loaded and it is now safe to make calls PhoneGap methods
- function onDeviceReady() {
- // 注册回退按钮事件监听器
- document.addEventListener("backbutton", onBackKeyDown, false); //返回键
- }
-
-
- function onConfirm(button) {
- if(window.location.hash=="#zhaopin" || window.location.hash==""){
- if(button==1) navigator.app.exitApp(); //选择了确定才执行退出
- }
-
- }
- // Show a custom confirmation dialog
- //
-
-
- function onBackKeyDown() {
- if(window.location.hash=="#zhaopin" || window.location.hash=="" ){
- navigator.notification.confirm(
- '确定要退出吗?', // message
- onConfirm, // callback to invoke with index of button pressed
- 'www.lpsrcw.com', // title
- '确定,取消' // buttonLabels
- );
- }else{
- navigator.app.backHistory();
- }
-
-
- }
- </script>
复制代码
|
|