I have tried a number of examples here but I can get my code to actually show a popup window before deletion. The code I use can be found here:
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
<script type="text/javascript">
function ConfirmDelete()
{
if (confirm("Delete Account?"))
location.href='linktoaccountdeletion';
}
</script>
echo '<input type="button" onclick="ConfirmDelete()" value="DELETE ACCOUNT">';
回答2:
You just need to use the onclick
method for your link or button:
<a href="DELETE_PAGE" onClick="return confirm('Delete This account?')">Delete Account</a>
回答3:
try this
<form action="url/to/delation_page" onSubmit="return confirm('are you sure?')">
</form>
回答4:
Just say
onclick="return confirm('Are you sure you want to delete?')"
^^^^^^ --> this is very important step...
回答5:
javascript confirmation
function doConfirm(id)
{
var ok = confirm("Are you sure to Delete?")
if (ok)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
window.location = "create_dealer.php"; // self page
}
}
xmlhttp.open("GET", "delete_dealer.php?id=" + id);
xmlhttp.send();
}
}
button for delete
<input type="button" onclick="doConfirm();"/>
回答6:
if u use on-click the data will be deleted but to view result u have to refresh the page manually instead use onSubmit="return confirm('are you sure?')"
think it helps !