The js Code in the confirmation dialog box is displayed before deletion. The js Code in the dialog box is displayed.

Source: Internet
Author: User

The js Code in the confirmation dialog box is displayed before deletion. The js Code in the dialog box is displayed.
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> confirm deletion </title>
<Script type = "text/javascript">
Function confirmd (){
Var msg = "are you sure you want to delete it? /N please confirm! ";
If (confirm (msg) = true ){
Return true;
} Else {
Return false;
}
}
</Script>
</Head>
<Body>
<A href = "http://www.baidu.com" onclick = "return confirmd ()"> Delete </a>
</Body>

</Html>



One type:

<A href = "javascript: if (confirm ('Are you sure you want to delete this content? ') Location = 'HTTP: // www.google.com' "> pop-up window </a>

Two types:

<Script language = "JavaScript">
Function delete_confirm (e)
{
If (event. srcElement. outerText = "delete ")
{
Event. returnValue = confirm ("deletion 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 types:

Function delete_confirm ()
{
If (window. confirm ('Are you sure you want to cancel the transaction? ')){
Alert ("OK ");
Return true;
} Else {
Alert ("cancel ");
Return false;
}
}

<A href = "http://www.baidu.com" onClick = "return delete_confirm ()"> Delete </a>


Four types:

<Script language = "JavaScript">

Function delete_confirm () <! -- Call Method -->
{
Event. returnValue = confirm ("deletion is unrecoverable. Are you sure you want to delete it? ");
}
</Script>


<A href = "http://www.baidu.com" onClick = "delete_confirm ()"> Delete </a>



When JS deletes a message, click OK to see whether to delete the dialog box. How can this problem be solved?

Function fn (){
If (confirm ("are you sure you want to delete ")){
Location. href = "page to jump after confirmation ";
} Else {
Location. href = "page to jump after cancellation ";
}
}

How can I use JS to pop up "are you sure you want to delete" when you click Delete ?" This dialog box?

<Script>
Function del (){
If (confirm ("are you sure you want to delete ")){
Alert ("yes ");
}
Else {
Alert ("no ")
Return;
}
}
</Script>
<Html>
<Input type = "button" value = "del" onclick = "del ();">
</Html>

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.