Thursday, March 9, 2017

Confirm Delete works in Chrome, doesn't work in Firefox

I have this bit of JavaScript in my web application:

<script>

document.getElementById("revDel").onclick = function() {myFunction()};

function myFunction() {

if (confirm("Confirm delete!")) {

}

else {

event.preventDefault();
}

}

</script>

It works fine in Chrome & IE; when a user attempts to delete a particular record, a prompt pops up and if they select "OK" the record gets deleted but if they click on "Cancel" the delete action is halted.

Unfortunately this doesn't work on Firefox; when the user clicks on delete, whatever option they click on, the record gets deleted either way.

Has anyone encountered this before and how did you go about solving it?



via Raymond Wachaga

Advertisement