I am using a 3rd party js that shows alert
's to the user, is there a way to catch the alert before it is displayed, and show something else instead? example:
function doOtherPeopleCode(){
sdk.doStuff(); //catch all sdk alerts
}
I am using a 3rd party js that shows alert
's to the user, is there a way to catch the alert before it is displayed, and show something else instead? example:
function doOtherPeopleCode(){
sdk.doStuff(); //catch all sdk alerts
}
Yes, you can simply replace the window.alert
method with your custom version. Inside this replacement you can add some checks and conditions and then decide if you want to call the cached version of window.alert
(which you store in a variable) or do something else.