Confirm () method
The Confirm () method displays a dialog box with the specified message and the OK and Cancel buttons.
Note: If the user clicks the OK button, confirm () returns TRUE. If you click the Cancel button, confirm () returns false
A:
Copy Code code as follows:
<a href= "javascript:if (' Do you really want to delete this content? ') location= ' http://www.baidu.com ' > pop-up window </a>
Two kinds:
Copy Code code as follows:
<script language= "JavaScript" >
function Delete_confirm (e)
{
if (Event.srcElement.outerText = = "Delete")
{
Event.returnvalue = Confirm ("Delete is unrecoverable, are you sure you want to delete it?") ");
}
}
Document.onclick = delete_confirm;
</script>
<a href= "delete.aspx" onclick= "delete_confirm" > Delete </a>
Three kinds:
Copy Code code as follows:
if (window.confirm) (' Are you sure you want to cancel the transaction? ')){
Alert ("OK");
return true;
}else{
Alert ("Cancel");
return false;
}
Four kinds:
Copy Code code as follows:
<script language= "JavaScript" >
function delete_confirm () <!--calling method-->
{
Event.returnvalue = Confirm ("Delete is unrecoverable, are you sure you want to delete it?") ");
}
</script>
A simpler way I used to do it myself.
, Simpler:
Copy Code code as follows:
<form name= "Form1" method= "Post" action= "xxx.htm" onsubmit= "Javascript:return window.confirm" (' Confirm submit? ') ' >