Alex Rivera | Logout

Is there a way to capture the alert ok button click event?

Asked 2012-07-24T22:30:57.103
16

Is there a way to capture the alert ok button click event? In jQuery?

Edit
Report

1 Answer

10

Disclaimer: This is a very bad thing to do.

Technically you could hook into it with this code:

window.alert = function(al, $){
    return function(msg) {
        al(msg);
        $(window).trigger("okbuttonclicked");
    };
}(window.alert, window.jQuery);



$(window).on("okbuttonclicked", function() {
    console.log("you clicked ok");
});

alert("something");

​

Demo: http://jsfiddle.net/W4d7J/1/

answered 2012-07-24T22:41:18.800

Your Answer