- <!DOCTYPE html>
- <html>
- <head>
- <title>Event Example</title>
- <script type="text/javascript" charset="utf-8" src="jquery-1.8.1.min.js"></script>
- <script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
- <script type="text/javascript" charset="utf-8">
- // Wait for Cordova to load
- // details plz see http://docs.phonegap.com/en/2.0.0/cordova_events_events.md.html#Events
- document.addEventListener("deviceready", onDeviceReadyEvent, false);
- document.addEventListener("pasue", onPasueEvent, false);
- document.addEventListener("resume", onResumeEvent, false);
- document.addEventListener("online", onlineEvent, false);
- document.addEventListener("offline", offlineEvent, false);
- document.addEventListener("backbutton", onBackbuttonEvent, false);
- document.addEventListener("batterycritical", onBatterycriticalEvent, false);
- document.addEventListener("batterylow", onBatterylowEvent, false);
- document.addEventListener("batterystatus", onBatterystatusEvent, false);
- document.addEventListener("menubutton", onMenubuttonEvent, false);
- document.addEventListener("startcallbutton", onStartcallbuttonEvent, false);
- document.addEventListener("volumedownbutton", onVolumedownbuttonEvent, false);
- document.addEventListener("volumeupbutton", onVolumeupbuttonEvent, false);
- // Cordova is ready
- //
- function onDeviceReadyEvent() {
- $("#msg").append("==>onDeviceReadyEvent<p/>");
- }
- function onPasueEvent() {
- $("#msg").append("==>onPasueEvent<p/>");
- }
- function onResumeEvent() {
- $("#msg").append("==>onResumeEvent<p/>");
- }
- function onlineEvent() {
- $("#msg").append("==>onlineEvent<p/>");
- }
- function offlineEvent() {
- $("#msg").append("==>offlineEvent<p/>");
- }
- function onBackbuttonEvent() {
- $("#msg").append("==>onBackbuttonEvent<p/>");
- }
- function onBatterycriticalEvent() {
- $("#msg").append("==>onBatterycriticalEvent<p/>");
- }
- function onBatterylowEvent() {
- $("#msg").append("==>onBatterylowEvent<p/>");
- }
- function onBatterystatusEvent() {
- $("#msg").append("==>onBatterystatusEvent<p/>");
- }
- function onMenubuttonEvent() {
- $("#msg").append("==>onMenubuttonEvent<p/>");
- }
- function onStartcallbuttonEvent() {
- $("#msg").append("==>onStartcallbuttonEvent<p/>");
- }
- function onVolumedownbuttonEvent() {
- $("#msg").append("==>onVolumedownbuttonEvent<p/>");
- }
- function onVolumeupbuttonEvent() {
- $("#msg").append("==>onVolumeupbuttonEvent<p/>");
- }
- </script>
- </head>
- <body>
- <h1>Event Example</h1>
- <div id="msg"></div>
- </body>
- </html>
2012年11月2日星期五
phonegap-event
监听各类事件,我用的是phonegap2.0.0的版本,越高级的版本支持功能就越多。
订阅:
博文评论 (Atom)
没有评论:
发表评论