Connected to WebmasterWorld JS Forum:
http://www.webmasterworld.com/javascript/3108046.htm
This method submits a form (the action directs to the delete page) and the onsubmit event confirms the action with the user. WARNING: This method will still delete if JavaScript is disabled!
<script type="text/javascript">
function confirmDelete() {
return confirm("Are you sure you want to delete?");
}
</script>
<form action="confirm_delete_action.php" onsubmit="return confirmDelete();">
<div>
<input type="submit" name="delete" value="Delete">
</div>
</form>
</script>
Perhaps a slightly more secure solution is to do everything in JavaScript, including the redirect. But if someone takes a look at the code they can then see the intended action and bypass the confirmation anyway - but then it is still a deliberate action. This is not a good solution, as it relies on JavaScript being enabled in the browser for it to work.
function performDelete(DestURL) {
var ok = confirm("Are you sure you want to delete?");
if (ok) {location.href = DestURL;}
return ok;
}
<a href="nojs.html" onclick="performDelete('confirm_delete_action.php'); return false;">Delete</a>
Need to send a confirmation to the destination (delete) page that it has been confirmed
[Delete]
[Home]