- Overview
- Platform Support
- The Command-Line Interface
- Platform Guides
- Using Plugman to Manage Plugins
- The config.xml File
- Icons and Splash Screens
- Embedding WebViews
- Plugin Development Guide
- Privacy Guide
- Whitelist Guide
- Accelerometer
- Camera
- Capture
- Compass
- Connection
- Contacts
- Device
- Events
- File
- Geolocation
- Globalization
- InAppBrowser
- Media
- Notification
- Splashscreen
- Storage
                    
                    This version of the documentation is outdated!
                    
                        Click here for the latest released version.
                    
                
            
            
            
            notification.alert
Shows a custom alert or dialog box.
navigator.notification.alert(message, alertCallback, [title], [buttonName])
- 
    message: Dialog message. (String) 
- 
    alertCallback: Callback to invoke when alert dialog is dismissed. (Function) 
- 
    title: Dialog title. (String) (Optional, defaults to Alert)
- 
    buttonName: Button name. (String) (Optional, defaults to OK)
Description
Most Cordova implementations use a native dialog box for this feature,
but some platforms use the browser's alert function, which is
typically less customizable.
Supported Platforms
- Amazon Fire OS
- Android
- BlackBerry 10
- iOS
- Tizen
- Windows Phone 7 and 8
- Windows 8
Quick Example
// Amazon Fire OS / Android / BlackBerry 10 (OS 5.0 and higher) / iOS / Tizen
//
function alertDismissed() {
    // do something
}
navigator.notification.alert(
    'You are the winner!',  // message
    alertDismissed,         // callback
    'Game Over',            // title
    'Done'                  // buttonName
);
Full Example
<!DOCTYPE html>
<html>
  <head>
    <title>Notification Example</title>
    <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
    <script type="text/javascript" charset="utf-8">
    // Wait for device API libraries to load
    //
    document.addEventListener("deviceready", onDeviceReady, false);
    // device APIs are available
    //
    function onDeviceReady() {
        // Empty
    }
    // alert dialog dismissed
        function alertDismissed() {
            // do something
        }
    // Show a custom alertDismissed
    //
    function showAlert() {
        navigator.notification.alert(
            'You are the winner!',  // message
            alertDismissed,         // callback
            'Game Over',            // title
            'Done'                  // buttonName
        );
    }
    </script>
  </head>
  <body>
    <p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p>
  </body>
</html>
Windows Phone 7 and 8 Quirks
- 
    There is no built-in browser alert, but you can bind one as follows to call alert()in the global scope:window.alert = navigator.notification.alert;
- 
    Both alertandconfirmare non-blocking calls, results of which are only available asynchronously.