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>