JavaScript window.confirm Confirm Cancel dialog box implementation code

Source: Internet
Author: User

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? ') '
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.