We use alert(text)
to give an alert in the window, there is a way to redefine this function so instead of displaying this default window it displays a custom made in HTML but without losing its real function, it would just be an exchange of the " design "of the dialog box without losing its real functionality.
According to the answers I can even guide me, but how to program the part that returns OK / CANCEL / NO
Type, this is my job:
window.safeConfirm = function(params, callback) {
if (typeof params === 'string') {
params = {
message: params
};
}
var result = false;
try {
result = confirm(params.message);
} catch (e) {
result = true;
}
setTimeout(function() {
callback(result);
}, 10);
};
It serves to give an alert in the form of dialogue "yes / no" and perform a function according to the user's response, its use would be something like:
safeConfirm({
type: 'ERROR_1',
message: 'lalalala'
}, function() {
window.location.reload();
});
If I reset the function as in the replies this function would not work and I would lose what I want is the functionality of the alert with the alert being done in HTML .. So, anyway, how to do?