change the title of a Window confirm ()

4

I would like to know if I could somehow change the title of a window confirm() because I'm developing an app using phonegap and when I call this window it presents me the title with the name of my html file, can I modify this? if so how?

    
asked by anonymous 17.12.2015 / 18:00

5 answers

3

You should pass the title as a parameter, for example:

notification.confirm('message',onConfirm,'title','Restart,Exit');

that is, the order of the parameters is: Message, function to be executed in the return, title and the "Labels" to be used in the buttons.

    
17.12.2015 / 18:10
4

You're probably using the org.apache.cordova.dialogs plugin.

Users/ft/projectname/platforms/ios/www/plugins/org.apache.cordova.dialogs/www/notification.js

Open the file Notification.js and find the snippet below.

/**
 * Open a native confirm dialog, with a customizable title and button text.
 * The result that the user selects is returned to the result callback.
 *
 * @param {String} message              Message to print in the body of the alert
 * @param {Function} resultCallback     The callback that is called when user clicks on a button.
 * @param {String} title                Title of the alert dialog (default: Confirm)
 * @param {Array} buttonLabels          Array of the labels of the buttons (default: ['OK', 'Cancel'])
 */
confirm: function(message, resultCallback, title, buttonLabels) {
    var _title = (title || "Confirm");
    var _buttonLabels = (buttonLabels || ["OK", "Cancel"]);

    // Strings are deprecated!
    if (typeof _buttonLabels === 'string') {
        console.log("Notification.confirm(string, function, string, string) is deprecated.  Use Notification.confirm(string, function, string, array).");
    }

And remove only "Confirm" and leave it blank:

var _title = (title || "Confirm"); -->  var _title = (title || "");

And now let's adjust the "Alert" part, find a similar code and do:

var _title = (title || "Alert"); --> var _title = (title || "");

I tested it on Android and it worked great, but I did not test with iOS.

See and tell me if it helped.

    
17.12.2015 / 18:09
3

Not possible, the alternative would be to use some kind of modal .

This limitation is for security reasons, a malicious person could change the URL shown in the confirmation window for example.

    
17.12.2015 / 18:06
2

You could use notification.confirm() of PhoneGap:

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

More details at:

  

link

    
17.12.2015 / 18:09
1

A very simple modal to use is the bootbox

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Minha Página</title>
<!-- CSS dependencies -->
<link rel="stylesheet" type="text/css" href="./bootstrap.min.css">
</head>
<body>
<p>Conteúdo. <a class="alerta" href=#>Alerta!</a></p>
<!-- dependências JS  -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script><scriptsrc="./bootstrap.min.js"></script>
<!-- código bootbox -->
<script src="./bootbox.min.js"></script>
<script>
    $(document).on("click", ".alerta", function(e) {
        bootbox.confirm("Olá Mundo!", function() {
            console.log("Alerta Callback");
        });
    });
</script>
</body>
</html>
  

Official link: link

    
17.12.2015 / 18:14