成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

PhoneGap API幫助文檔翻譯Notification提醒

移動開發
PhoneGap API幫助文檔翻譯Notification提醒是本文要介紹的內容,主要是來了解PhoneGap API文檔的內容,具體PhoneGap API文檔內容的詳解來看本文。

PhoneGap API幫助文檔翻譯Notification提醒是本文要介紹的內容,主要是來了解PhoneGap API文檔的內容,具體PhoneGap API文檔內容的詳解來看本文,設備的視覺、聽覺和觸覺通知。

方法:

  1. notification.alert  
  2. notification.confirm  
  3. notification.beep  
  4. notification.vibrate  
  5. notification.alert  

顯示一個定制的警告或對話框。

  1. navigator.notification.alert(message, alertCallback, [title], [buttonName]);    
  2. navigator.notification.alert(message, alertCallback, [title], [buttonName]); 

message:對話框信息。(字符串類型)

alertCallback:當警告對話框被忽略時調用的回調函數。(函數類型)

title:對話框標題。(字符串類型)(可選項,默認值為“Alert”)

buttonName:按鈕名稱(字符串類型)(可選項,默認值為“OK”)

說明:

大多數PhoneGap使用本地對話框實現該功能。然而,一些平臺只是簡單的使用瀏覽器的alert函數,而這種方法通常是不能定制的。

支持的平臺:

Android

BlackBerry (OS 4.6)

BlackBerry WebWorks (OS 5.0或更高版本)

iPhone

簡單的范例:

  1. // Android / BlackBerry WebWorks (OS 5.0 and higher) // iPhone    
  2. function alertDismissed() {    
  3.     // 進行處理    
  4. }    
  5.     
  6. navigator.notification.alert(    
  7.     'You are the winner!',  // 顯示信息    
  8.     alertDismissed,         // 警告被忽視的回調函數    
  9.     'Game Over',            // 標題    
  10.     'Done'                  // 按鈕名稱    
  11. );    
  12.     
  13. // BlackBerry (OS 4.6) // webOS    
  14. navigator.notification.alert('You are the winner!');    
  15. // Android / BlackBerry WebWorks (OS 5.0 and higher) // iPhone  
  16. function alertDismissed() {  
  17.  // 進行處理  
  18. }  
  19.  
  20. navigator.notification.alert(  
  21.  'You are the winner!',  // 顯示信息  
  22.     alertDismissed,         // 警告被忽視的回調函數  
  23.     'Game Over',            // 標題  
  24.     'Done'                  // 按鈕名稱  
  25. );  
  26.  
  27. // BlackBerry (OS 4.6) // webOS  
  28. navigator.notification.alert('You are the winner!');  
  29. 完整的范例:  
  30. view plaincopy to clipboardprint?<!DOCTYPE html>    
  31. <html>    
  32. <head>        
  33. <title>Notification Example</title>    
  34.     
  35. <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>    
  36. <script type="text/javascript" charset="utf-8">    
  37.     
  38.     // 等待加載PhoneGap    
  39.     document.addEventListener("deviceready", onDeviceReady, false);     
  40.         
  41.     // PhoneGap加載完畢    
  42.     function onDeviceReady() {    
  43.         // 空    
  44.     }    
  45.         
  46.     // 警告對話框被忽視    
  47.     function alertDismissed() {    
  48.         // 進行處理    
  49.     }    
  50.         
  51.     // 顯示一個定制的警告框    
  52.     function showAlert() {    
  53.         navigator.notification.alert(    
  54.             'You are the winner!',  // 顯示信息    
  55.             alertDismissed,         // 警告被忽視的回調函數    
  56.             'Game Over',            // 標題    
  57.             'Done'                  // 按鈕名稱    
  58.         );    
  59.     }    
  60.     
  61. </script>    
  62. </head>    
  63. <body>    
  64.     <p><a href="#" onclick="showConfirm(); return false;">Show Confirm</a></p>    
  65. </body>    
  66. </html>    
  67. <!DOCTYPE html> 
  68. <html> 
  69. <head>   
  70. <title>Notification Example</title> 
  71.  
  72. <script type="text/javascript" charset="utf-8" src="phonegap.js"></script> 
  73. <script type="text/javascript" charset="utf-8"> 
  74.  
  75.  // 等待加載PhoneGap  
  76.  document.addEventListener("deviceready", onDeviceReady, false);   
  77.    
  78.  // PhoneGap加載完畢  
  79.  function onDeviceReady() {  
  80.   // 空  
  81.  }  
  82.    
  83.  // 警告對話框被忽視  
  84.  function alertDismissed() {  
  85.   // 進行處理  
  86.  }  
  87.    
  88.  // 顯示一個定制的警告框  
  89.  function showAlert() {  
  90.   navigator.notification.alert(  
  91.    'You are the winner!',  // 顯示信息  
  92.    alertDismissed,         // 警告被忽視的回調函數  
  93.    'Game Over',            // 標題  
  94.    'Done'                  // 按鈕名稱  
  95.   );  
  96.  }  
  97.  
  98. </script> 
  99. </head> 
  100. <body> 
  101.  <p><a href="#" onclick="showConfirm(); return false;">Show Confirm</a></p> 
  102. </body> 
  103. </html> 
  104. notification.confirm   

顯示一個可定制的確認對話框。

  1. navigator.notification.confirm(message, confirmCallback, [title], [buttonLabels]);    
  2. navigator.notification.confirm(message, confirmCallback, [title], [buttonLabels]); 

message:對話框信息。(字符串類型)

confirmCallback:按下按鈕后觸發的回調函數,返回按下按鈕的索引(1、2或3)。(函數類型)

title:對話框標題。(字符串類型)(可選項,默認值為“Confirm”)

buttonLabels:逗號分隔的按鈕標簽字符串。(字符串類型)(可選項,默認值為“OK、Cancel”)

#p#

PhoneGap API說明:

notification.confirm函數顯示一個定制性比瀏覽器的confirm函數更好的本地對話框。

支持的平臺:

Android

BlackBerry WebWorks (OS 5.0或更高版本)

iPhone

簡單的范例:

  1. // 處理確認對話框返回的結果    
  2. function onConfirm(button) {    
  3.     alert('You selected button ' + button);    
  4. }    
  5.     
  6. // 顯示一個定制的確認對話框    
  7. function showConfirm() {    
  8.     navigator.notification.confirm(    
  9.         'You are the winner!',  // 顯示信息    
  10.         onConfirm,              // 按下按鈕后觸發的回調函數,返回按下按鈕的索引    
  11.         'Game Over',            // 標題    
  12.         'Restart,Exit'          // 按鈕標簽    
  13.     );    
  14.  }    
  15. // 處理確認對話框返回的結果  
  16. function onConfirm(button) {  
  17.  alert('You selected button ' + button);  
  18. }  
  19.  
  20. // 顯示一個定制的確認對話框  
  21. function showConfirm() {  
  22.     navigator.notification.confirm(  
  23.      'You are the winner!',  // 顯示信息  
  24.      onConfirm,              // 按下按鈕后觸發的回調函數,返回按下按鈕的索引  
  25.      'Game Over',            // 標題  
  26.      'Restart,Exit'          // 按鈕標簽  
  27.     );  
  28.  } 

完整的范例:

  1. <!DOCTYPE html>    
  2. <html>    
  3. <head>        
  4. <title>Notification Example</title>    
  5.     
  6. <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>    
  7. <script type="text/javascript" charset="utf-8">    
  8.         
  9.     // 等待加載PhoneGap    
  10.     document.addEventListener("deviceready", onDeviceReady, false);     
  11.         
  12.     // PhoneGap加載完畢    
  13.     function onDeviceReady() {    
  14.         // 空    
  15.     }    
  16.         
  17.     // 處理確認對話框返回的結果    
  18.     function onConfirm(button) {    
  19.         alert('You selected button ' + button);    
  20.     }    
  21.         
  22.     // 顯示一個定制的確認對話框    
  23.     function showConfirm() {    
  24.         navigator.notification.confirm(    
  25.             'You are the winner!',  // 顯示信息    
  26.             onConfirm,              // 按下按鈕后觸發的回調函數,返回按下按鈕的索引       
  27.             'Game Over',            // 標題    
  28.             'Restart,Exit'          // 按鈕標簽    
  29.         );    
  30.     }    
  31.     
  32. </script>    
  33. </head>    
  34. <body>    
  35.     <p><a href="#" onclick="showConfirm(); return false;">Show Confirm</a></p>    
  36. </body>    
  37. </html>    
  38. <!DOCTYPE html> 
  39. <html> 
  40. <head>   
  41. <title>Notification Example</title> 
  42.  
  43. <script type="text/javascript" charset="utf-8" src="phonegap.js"></script> 
  44. <script type="text/javascript" charset="utf-8"> 
  45.    
  46.  // 等待加載PhoneGap  
  47.  document.addEventListener("deviceready", onDeviceReady, false);   
  48.    
  49.  // PhoneGap加載完畢  
  50.  function onDeviceReady() {  
  51.   // 空  
  52.  }  
  53.    
  54.  // 處理確認對話框返回的結果  
  55.  function onConfirm(button) {  
  56.   alert('You selected button ' + button);  
  57.  }  
  58.    
  59.  // 顯示一個定制的確認對話框  
  60.  function showConfirm() {  
  61.   navigator.notification.confirm(  
  62.    'You are the winner!',  // 顯示信息  
  63.    onConfirm,              // 按下按鈕后觸發的回調函數,返回按下按鈕的索引   
  64.    'Game Over',            // 標題  
  65.    'Restart,Exit'          // 按鈕標簽  
  66.   );  
  67.  }  
  68.  
  69. </script> 
  70. </head> 
  71. <body> 
  72.  <p><a href="#" onclick="showConfirm(); return false;">Show Confirm</a></p> 
  73. </body> 
  74. </html> 
  75. notification.beep   

設備將發出蜂鳴聲。

  1. navigator.notification.beep(times);    
  2. navigator.notification.beep(times); 

times:蜂鳴聲的重復次數。(數字類型)

支持的平臺:

Android

BlackBerry (OS 4.6)

BlackBerry WebWorks (OS 5.0或更高版本)

iPhone

簡單的范例:

  1. // 蜂鳴2次!    
  2. navigator.notification.beep(2);    
  3. // 蜂鳴2次!  
  4. navigator.notification.beep(2); 

完整的范例:

  1. <!DOCTYPE html>    
  2. <html>    
  3. <head>        
  4. <title>Notification Example</title>    
  5.     
  6. <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>    
  7. <script type="text/javascript" charset="utf-8">    
  8.     
  9. // 等待加載PhoneGap    
  10. document.addEventListener("deviceready", onDeviceReady, false);     
  11.     
  12. // PhoneGap加載完畢    
  13. function onDeviceReady() {    
  14.     // 空    
  15. }    
  16.     
  17. // 顯示一個定制的警告框    
  18. function showAlert() {    
  19.     navigator.notification.alert(    
  20.         'You are the winner!',  // 顯示信息    
  21.         'Game Over',            // 標題    
  22.         'Done'                  // 按鈕名稱    
  23.     );    
  24. }    
  25.     
  26. // 蜂鳴三次    
  27. function playBeep() {    
  28.     navigator.notification.beep(3);    
  29. }    
  30.     
  31. // 震動兩秒    
  32. function vibrate() {    
  33.     navigator.notification.vibrate(2000);    
  34. }    
  35.     
  36. </script>    
  37. </head>    
  38. <body>    
  39.     <p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p>    
  40.     <p><a href="#" onclick="playBeep(); return false;">Play Beep</a></p>    
  41.     <p><a href="#" onclick="vibrate(); return false;">Vibrate</a></p>    
  42. </body>    
  43. </html>    
  44. <!DOCTYPE html> 
  45. <html> 
  46. <head>   
  47. <title>Notification Example</title> 
  48.  
  49. <script type="text/javascript" charset="utf-8" src="phonegap.js"></script> 
  50. <script type="text/javascript" charset="utf-8"> 
  51.  
  52. // 等待加載PhoneGap  
  53. document.addEventListener("deviceready", onDeviceReady, false);   
  54.  
  55. // PhoneGap加載完畢  
  56. function onDeviceReady() {  
  57.     // 空  
  58. }  
  59.  
  60. // 顯示一個定制的警告框  
  61. function showAlert() {  
  62.     navigator.notification.alert(  
  63.      'You are the winner!',  // 顯示信息  
  64.      'Game Over',            // 標題  
  65.      'Done'                  // 按鈕名稱  
  66.     );  
  67. }  
  68.  
  69. // 蜂鳴三次  
  70. function playBeep() {  
  71.     navigator.notification.beep(3);  
  72. }  
  73.  
  74. // 震動兩秒  
  75. function vibrate() {  
  76.     navigator.notification.vibrate(2000);  
  77. }  
  78.  
  79. </script> 
  80. </head> 
  81. <body> 
  82.  <p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p> 
  83.  <p><a href="#" onclick="playBeep(); return false;">Play Beep</a></p> 
  84.  <p><a href="#" onclick="vibrate(); return false;">Vibrate</a></p> 
  85. </body> 
  86. </html> 

#p#

Android的特異情況:

Androids會播放在“設置/音效及顯示”面板中指定的默認“通知鈴聲”。

iPhone的特異情況:

忽略蜂鳴次數參數。

iPhone沒有本地的蜂鳴API。

PhoneGap通過多媒體API播放音頻文件來實現蜂鳴。

用戶必須提供一個包含所需的蜂鳴聲的文件。

此文件播放時長必須短于30秒,位于www/root,并且必須命名為beep.wav。

notification.vibrate  
 
使設備震動指定的時長。

  1. navigator.notification.vibrate(milliseconds);    
  2. navigator.notification.vibrate(milliseconds); 

time:以毫秒為單位的設備震動時長,1000毫秒為1秒。(數字類型)

支持的平臺:

Android

BlackBerry (OS 4.6)

BlackBerry WebWorks (OS 5.0或更高版本)

iPhone

簡單的范例:

  1. // 震動2.5秒    
  2. navigator.notification.vibrate(2500);    
  3. // 震動2.5秒  
  4. navigator.notification.vibrate(2500); 

完整的范例:

  1. <!DOCTYPE html>    
  2. <html>    
  3. <head>        
  4. <title>Notification Example</title>    
  5.     
  6. <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>    
  7. <script type="text/javascript" charset="utf-8">    
  8.     
  9. // 等待加載PhoneGap    
  10. document.addEventListener("deviceready", onDeviceReady, false);     
  11.     
  12. // PhoneGap加載完畢    
  13. function onDeviceReady() {    
  14.     //空    
  15. }    
  16.     
  17. // 顯示定制警告框    
  18. function showAlert() {    
  19.     navigator.notification.alert(    
  20.         'You are the winner!',  // 顯示信息    
  21.         'Game Over',            // 標題    
  22.         'Done'                  // 按鈕名稱    
  23.     );    
  24. }    
  25.     
  26. // 響三次    
  27. function playBeep() {    
  28.     navigator.notification.beep(3);    
  29. }    
  30.     
  31. // 震動兩秒    
  32. function vibrate() {    
  33.     navigator.notification.vibrate(2000);    
  34. }    
  35.     
  36. </script>    
  37. </head>    
  38. <body>    
  39.     <p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p>    
  40.     <p><a href="#" onclick="playBeep(); return false;">Play Beep</a></p>    
  41.     <p><a href="#" onclick="vibrate(); return false;">Vibrate</a></p>    
  42. </body>    
  43. </html>    
  44. <!DOCTYPE html> 
  45. <html> 
  46. <head>   
  47. <title>Notification Example</title> 
  48.  
  49. <script type="text/javascript" charset="utf-8" src="phonegap.js"></script> 
  50. <script type="text/javascript" charset="utf-8"> 
  51.  
  52. // 等待加載PhoneGap  
  53. document.addEventListener("deviceready", onDeviceReady, false);   
  54.  
  55. // PhoneGap加載完畢  
  56. function onDeviceReady() {  
  57.     //空  
  58. }  
  59.  
  60. // 顯示定制警告框  
  61. function showAlert() {  
  62.     navigator.notification.alert(  
  63.      'You are the winner!',  // 顯示信息  
  64.      'Game Over',            // 標題  
  65.      'Done'                  // 按鈕名稱  
  66.     );  
  67. }  
  68.  
  69. // 響三次  
  70. function playBeep() {  
  71.     navigator.notification.beep(3);  
  72. }  
  73.  
  74. // 震動兩秒  
  75. function vibrate() {  
  76.     navigator.notification.vibrate(2000);  
  77. }  
  78.  
  79. </script> 
  80. </head> 
  81. <body> 
  82.  <p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p> 
  83.  <p><a href="#" onclick="playBeep(); return false;">Play Beep</a></p> 
  84.  <p><a href="#" onclick="vibrate(); return false;">Vibrate</a></p> 
  85. </body> 
  86. </html> 

iPhone的特異情況:

time:忽略時長參數,震動時長為預先設定值。

簡單的范例:

  1. <span style="font-size:13px;">navigator.notification.vibrate();    
  2. navigator.notification.vibrate(2500);   // 2500被忽略掉</span>   

小結:PhoneGap API幫助文檔翻譯Notification提醒的內容介紹完了,希望通過:PhoneGap API文檔內容的學習能對你有所幫助!

責任編輯:zhaolei 來源: 網絡轉載
相關推薦

2011-09-13 14:40:16

PhoneGap AP

2011-09-13 16:08:58

PhoneGap AP

2011-09-13 10:17:26

PhoneGap AP

2011-09-13 10:40:25

PhoneGap AP

2011-09-13 11:06:08

PhoneGap AP

2011-09-13 14:07:45

PhoneGap AP

2011-09-13 15:51:11

PhoneGap AP

2011-09-13 16:24:11

PhoneGap AP

2011-12-22 10:33:39

PhoneGap APNotificatio

2011-09-13 13:17:27

PhoneGap AP

2011-10-11 09:50:44

PhoneGap常見問題

2011-10-11 09:03:57

常見問題PhoneGap

2011-12-19 15:30:25

AccelerometPhoneGap AP

2011-12-19 16:26:39

PhoneGap APCapture

2011-12-20 13:32:52

PhoneGap APContacts

2011-12-20 16:09:57

PhoneGap APDevice

2011-12-21 21:56:45

PhoneGap APFile

2011-12-22 09:54:40

PhoneGap APMedia

2011-12-22 10:45:32

PhoneGap APStorage

2011-12-20 15:34:55

PhoneGap APConnection
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 欧美.com| 91精品久久久久久综合五月天 | 成人h免费观看视频 | 中文字幕成人 | 一级黄色毛片免费 | 天天澡天天操 | 欧美日韩在线成人 | 成人午夜激情 | 国产精品久久久亚洲 | 欧美xxxx网站 | 国产伦一区二区三区四区 | 欧美日韩1区 | 久久成 | 亚洲视频免费播放 | 国产电影一区二区 | 国产四区 | 在线免费国产 | 97人人干 | 在线免费观看毛片 | 久久看看 | 华丽的挑战在线观看 | 久久久久久999 | 欧美黄色性生活视频 | 乳色吐息在线观看 | 国产成人在线一区 | 国产性色视频 | 小早川怜子xxxxaⅴ在线 | 国产精品久久久久久亚洲调教 | 亚洲精品在线看 | 91精品国产综合久久国产大片 | 国产精品久久久久久久久久软件 | 国产精品夜夜夜一区二区三区尤 | 日日天天 | 色综合久久久 | 国产视频精品在线观看 | 高清av一区| 国产乱码精品1区2区3区 | 日韩视频一区二区 | 国产精品亚洲精品日韩已方 | 久久日韩粉嫩一区二区三区 | 天天干天天色 |