Home > Web Front-end > JS Tutorial > Javascript implements pop-up confirmation box before deletion

Javascript implements pop-up confirmation box before deletion

高洛峰
Release: 2016-12-17 13:49:27
Original
1413 people have browsed it

Requirement: When the user clicks the delete button, a confirmation box will pop up. If the user clicks "OK", the deletion operation will be performed. Otherwise, the

JS code

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

html code

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

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>
Copy after login

Method 3:

<a href="javascript:if(confirm(&#39;确实要删除吗?&#39;))location=&#39;jb51.php?id=&#39;">删除</a>
Copy after login
will not be executed

Method 4:

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

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

For more javascript implementation of pop-up confirmation box before deletion related articles, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template