Confirm in js implements the method of popping up the confirmation box before performing the operation
- 2020-03-30 04:15:41
- OfStack
The example in this article describes the method of pop-up confirmation box before the confirmation implementation in js. Share with you for your reference. The specific implementation method is as follows:
Now there are many ways to pop up a confirmation prompt before deleting or doing anything else. The most basic one is to use the built-in confirmation function of js
The simplest usage is as follows:
Confirm for mouse events
<a href="#" onclick= "if(confirm( ' Are you sure? ')==false)return false; "> Click ok </a>
Think of a simple call You can do that
<a href="#" onclick= "return confirm(' Whether or not sure ');"> Click ok </a>
After clicking the hyperlink, if you click ok, you go to the address to which the hyperlink is connected. If you click cancel do not execute the hyperlink
Cases.
<script type="text/javascript" language="javascript">
<!--
function confirmAct()
{
if(confirm(' Are you sure you want to do this ?'))
{
return true;
}
return false;
}
//-->
</script>
<a href="operate.php?mod=user&act=delete&id=564" onclick="return confirmAct();"> Perform operations </a>
Usage:
Onclick ="return confirmAct();" Add the code
case
<span onclick="return confirmAct();"> Click and I'll try </span>