Phonegap API help document translation notification

Source: Internet
Author: User

Phonegap APINotification for help document translation is the content to be introduced in this article, mainly to understandPhonegap APIDocument Content, detailsPhonegap APIThis document describes the visual, auditory, and tactile notifications of devices.

Method:

  1. Notification. Alert
  2. Notification. Confirm
  3. Notification. BEEP
  4. Notification. vibrate
  5. Notification. Alert

Displays a custom warning or dialog box.

  1. Navigator. Notification. Alert (message, alertcallback, [title], [buttonname]);
  2. Navigator. Notification. Alert (message, alertcallback, [title], [buttonname]);

Message: Dialog Box Information. (String type)

Alertcallback: the callback function called when the warning dialog box is ignored. (Function type)

Title: The title of the dialog box. (String type) (optional, default value: "alert ")

Buttonname: button name (string type) (optional, default value: "OK ")

Note:

Most phonegap uses the local dialog box to implement this function. However, some platforms simply use the alert function of the browser, which is usually not customizable.

Supported platforms:

Android

BlackBerry (operating system 4.6)

Blackberry webworks (OS 5.0 or later)

IPhone

Simple Example:

  1. // Android/BlackBerry webworks (OS 5.0 and higher) // iPhone
  2. Function alertdismissed (){
  3. // Process
  4. }
  5. Navigator. Notification. Alert (
  6. 'You are the winner! ', // Display information
  7. Alertdismissed, // warning the ignored callback function
  8. 'Game over', // Title
  9. 'Done' // button name
  10. );
  11. // BlackBerry (operating system 4.6) // WebOS
  12. Navigator. Notification. Alert ('you are the winner! ');
  13. // Android/BlackBerry webworks (OS 5.0 and higher) // iPhone
  14. Function alertdismissed (){
  15. // Process
  16. }
  17.  
  18. Navigator. Notification. Alert (
  19. 'You are the winner! ', // Display information
  20. Alertdismissed, // warning the ignored callback function
  21. 'Game over', // Title
  22. 'Done' // button name
  23. );
  24.  
  25. // BlackBerry (operating system 4.6) // WebOS
  26. Navigator. Notification. Alert ('you are the winner! ');
  27. Complete example:
  28. View plaincopy to clipboardprint?>
  29. <HTML>
  30. <Head>
  31. <Title> notification exampletitle>
  32. <SCRIPT type = "text/JavaScript" charset = "UTF-8" src = "phonegap. js"> SCRIPT>
  33. <SCRIPT type = "text/JavaScript" charset = "UTF-8">
  34. // Wait for loading phonegap
  35. Document. addeventlistener ("deviceready", ondeviceready, false );
  36. // Phonegap loaded
  37. Function ondeviceready (){
  38. // Null
  39. }
  40. // The warning dialog box is ignored.
  41. Function alertdismissed (){
  42. // Process
  43. }
  44. // Display a custom warning box
  45. Function showalert (){
  46. Navigator. Notification. Alert (
  47. 'You are the winner! ', // Display information
  48. Alertdismissed, // warning the ignored callback function
  49. 'Game over', // Title
  50. 'Done' // button name
  51. );
  52. }
  53. SCRIPT>
  54. Head>
  55. <Body>
  56. <P> <a href = "#" onclick = "showconfirm (); Return false;"> show confirma> P>
  57. Body>
  58. HTML>
  59. >
  60. <HTML>
  61. <Head>
  62. <Title> notification exampletitle>
  63.  
  64. <SCRIPT type = "text/JavaScript" charset = "UTF-8" src = "phonegap. js"> SCRIPT>
  65. <SCRIPT type = "text/JavaScript" charset = "UTF-8">
  66.  
  67. // Wait for loading phonegap
  68. Document. addeventlistener ("deviceready", ondeviceready, false );
  69. // Phonegap loaded
  70. Function ondeviceready (){
  71. // Null
  72. }
  73. // The warning dialog box is ignored.
  74. Function alertdismissed (){
  75. // Process
  76. }
  77. // Display a custom warning box
  78. Function showalert (){
  79. Navigator. Notification. Alert (
  80. 'You are the winner! ', // Display information
  81. Alertdismissed, // warning the ignored callback function
  82. 'Game over', // Title
  83. 'Done' // button name
  84. );
  85. }
  86.  
  87. SCRIPT>
  88. Head>
  89. <Body>
  90. <P> <a href = "#" onclick = "showconfirm (); Return false;"> show confirma> P>
  91. Body>
  92. HTML>
  93. Notification. Confirm

A Customizable confirmation dialog box is displayed.

  1. Navigator. Notification. Confirm (message, confirmcallback, [title], [buttonlabels]);
  2. Navigator. Notification. Confirm (message, confirmcallback, [title], [buttonlabels]);

Message: Dialog Box Information. (String type)

Confirmcallback: the callback function triggered after the button is pressed. The index (1, 2, or 3) of the pressed button is returned ). (Function type)

Title: The title of the dialog box. (String type) (optional, default value: "Confirm ")

Buttonlabels: A comma-separated button tag string. (String type) (optional, default value: "OK, cancel ")

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.