jquery – change the title of a window confirm()

Question:

I would like to know if somehow I would be able to modify the title of a window confirm() , since I am developing an app using phonegap and when I call this window it shows me the title with the name of my html file, can I modify this? if yes how?

Answer:

You are probably using the org.apache.cordova.dialogs plugin.

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

Open the Notification.js file 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 just remove the "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 beautifully, but I didn't test it on iOS.

See and tell me if it helped.

Scroll to Top