Home  >  Article  >  Web Front-end  >  Javascript implements pop-up confirmation box before deletion_javascript skills

Javascript implements pop-up confirmation box before deletion_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:56:391165browse

Requirement: When the user clicks the delete button, a confirmation box will pop up. If the user clicks "OK", the deletion operation will be executed, otherwise it will not be executed

JS code

function del() {
var msg = "您真的确定要删除吗?\n\n请确认!";
if (confirm(msg)==true){
return true;
}else{
return false;
}
}

html code

<a href="" onclick="javascript:return del();">删除</a>

Method 2:

<!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>确认是否删除</title> 
<script type="text/javascript"> 
function del(){ 
if(!confirm("确认要删除?")){ 
window.event.returnValue = false; 
} 
} 
</script> 
</head> 
<body> 
<a href="http://www.baidu.com" onclick="return del()">删除</a> 
</body> 
</html> 

Method three:

<a href="javascript:if(confirm('确实要删除吗&#63;'))location='jb51.php&#63;id='">删除</a>

Method 4:

<script type="text/javascript" language="javascript"> 
<!-- 
function confirmAct() 
{ 
  if(confirm('确定要执行此操作吗&#63;')) 
  { 
    return true; 
  } 
  return false; 
} 
//-->
</script> 
 
<a href="operate.php&#63;mod=user&act=delete&id=564" onclick="return confirmAct();">执行操作</a>

The above is the entire content of this article, I hope you all like it.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn