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:
The code is as follows |
Copy Code |
<a href= "javascript:if (' Do you really want to delete this content? ') location= ' http://www.google.com ' > pop-up window </a> |
Two kinds:
The code is as follows |
Copy Code |
<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:
The code is as follows |
Copy Code |
if (window.confirm) (' Are you sure you want to cancel the transaction? ')){ Alert ("OK"); return true; }else{ Alert ("Cancel"); return false; } |
Four kinds:
The code is as follows |
Copy Code |
<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:
code is as follows |
copy code |
<form name= "Form1" method= "Post" action= "xxx.htm" onsubmit= "Javascript:return window.confirm (' Confirm submit? ') ' |