2
We use alert(text)
to give an Alert in the window, there is a way to reset this function to instead of displaying this default window it displays a custom made in HTML but without losing its real function, it would just be a change of the "design" of the dialog box without losing its real functionality.
According to answers I can even orient myself, but how to program the part that returns the OK/CANCEL/NO
Like, this job of mine:
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 "yes/no" dialog 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 responses this function would not work and I would lose what I want is Alert functionality with Alert being done in HTML.. So after all, how to do?
Renan, this
this
refers to the_alert
andarguments
refers to themsg
? So in practice, it’s like you’re doing something like:var a = function(msg) { console.log(msg); return alert(msg); };
, only by keeping the namealert
to the function? Just to be sure! : P– José
Yes I wanted to keep the Alert function but not it in its entirety (displaying the window...) please see my updated question please?
– Vinícius Lara
@Renan really I shuffled.. I’ll have to resort to a plugin
– Vinícius Lara