发布网友 发布时间:2022-04-20 00:15
共2个回答
懂视网 时间:2022-04-20 04:37
这次给大家带来phonegap实现提示操作详解,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('Game Over!',alertCallback,'Game Over!','Done'); } //警告的回调 function alertCallback(){ } //显示一个自定义的确认对话框 function showConfirm(){ navigator.notification.confirm('Game Over!',onConfirm,'Game Over!','Restart,Exit'); } //确认对话框的回调 function onConfirm(button){ alert('You selected button '+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>
相信看了本文案例你已经掌握了方法,更多精彩请关注Gxl网其它相关文章!
推荐阅读:
phonegap创建联系人详解
不刷新的前提下怎样改变当前url的代码
热心网友 时间:2022-04-20 01:45
如何通过phonegap安卓插件实现复制(到剪贴板)黏贴操作 今天试验了phonegap的复制(到剪贴板)黏贴操作发现还蛮好用 下面说说怎么用: lz按照教程写了一个demo,大家可以去我qq群共享下载:250395324(自己写死了一段文字然后复制到剪贴板最后输出显示弹出屏幕) 1.首先我们可以去github下载插件 2.然后按照说明的教程一步一步去配置: The plugin creates the object window.plugins.clipboardManager with the methods copy(str, success, fail) that copies the given string paste(success, fail) that returns the text from the Clipboard success and fail are callback functions. An example for copy: window.plugins.clipboardManager.copy( "the text to copy", function(r){alert("copy is successful")}, function(e){alert(e)} ); An example for paste: window.plugins.clipboardManager.paste( function(r){alert("The text in the clipboard is " + r)}, function(e){alert(e)} );