Javascript Confirm Delete Code

Ohh, You are a web developer? Looking for a pop up Javascript confirmation for your delete or Edit Icon in your code in PHP or JSP or so. Here is what i suggest.

Option 1:

<a href="deletepage.php?id=1" onclick="return confirm('Are you sure you want to delete?')">Delete</a>

Option 2:

function confirmDelete(dUrl) {
  if (confirm("Are you sure you want to delete")) {
    document.location = dUrl;

<a href="javascript:confirmDelete('deletepage.php?id=1')">Delete</a>

I feel you would like to use the above one liner code 😉 It is best.

  • simon delos reyes

    I have a site that uses a artwork gallery for the users, I am using a js to delete a file, the problem is it don’t delete, it pop ups but no deletion. below are the codes that i have

    var tempImageID = 0;
    jQuery(document).ready(function() {

    jQuery( “#dialog” ).dialog({ autoOpen: false, buttons: { “Yes”: function() { DeleteArtwork(tempImageID); jQuery(this).dialog(“close”); }, “No – Cancel”: function() {jQuery(this).dialog(“close”);} } });

Connect on Skype or Google+
A.Niraj Kumar’s Present Address
Siva Nagar
530018, (Vizag)
Andhra Pradesh, India
Photo of A.Niraj Kumar

Call New York (USA): +1-(646)-666-9606
Call London (UK): +44-020-3290-9606
Call India: +91-9492247412 (Mobile)