Confirmation box for delete?

Hi guys,

I need little help here,
I have the codes here,


<!DOCTYPE html>
<html>
<body>

<p>Click the button to display a confirm box.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction()
{
var x;
var r=confirm("Press a button!");
if (r==true)
  {
  x="You pressed OK!";
  }
else
  {
  x="You pressed Cancel!";
  }
document.getElementById("demo").innerHTML=x;
}
</script>

</body>
</html>

The codes above is just a confirmation box.
What I wanted here is to apply this into delete URL.
Whenever I click the delete link this confirmation box will popup (YES or NO).
When YES is clicked it will continue to delete.
If NO is clicked it will simply cancel.

This is just basic really.

Thanks in advance.

You need to add a return false; statement to the script after x=“You pressed Cancel!”;