PHP前端开发

phonegap进行提示操作的具体示例代码分享

百变鹏仔 2个月前 (10-18) #H5教程
文章标签 示例

下面小编就为大家带来一篇使用phonegap进行提示操作的具体方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧

常有下面四种方式:

<!DOCTYPE html> <html>       <head>         <meta charset="UTF-8">         <title>Notifications</title>           <script type="text/javascript" charset="UTF-8" src="cordova.js"></script>         <script type="text/javascript" charset="UTF-8">           document.addEventListener("deviceready", onDeviceReady, false);             function onDeviceReady() {                 checkConnection();             }                           //显示自定义的警告             function showAlert(){                 navigator.notification.alert(&#39;Game Over!&#39;,alertCallback,&#39;Game Over!&#39;,&#39;Done&#39;);             }             //警告的回调             function alertCallback(){                               }                           //显示一个自定义的确认对话框             function showConfirm(){                 navigator.notification.confirm(&#39;Game Over!&#39;,onConfirm,&#39;Game Over!&#39;,&#39;Restart,Exit&#39;);             }             //确认对话框的回调             function onConfirm(button){                 alert(&#39;You selected button &#39;+button);             }                           //鸣叫两次             function playBeep(){                 navigator.notification.beep(2);             }                           //振动             function vibrate(){                 navigator.notification.vibrate(4000);             }                       </script>     </head>       <body onload="onLoad()">         <p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p>         <p><a href="#" onclick="showConfirm(); return false;">Show Confirmation</a></p>         <p><a href="#" onclick="playBeep() return false;">Play Beep</a></p>         <p><a href="#" onclick="vibrate() return false;">Vibrate</a></p>     </body>   </html>