刪除前彈出確認對話框的js代碼

 
<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 confirmd() {  
            var msg = "您真的確定要刪除嗎?/n/n請確認!";  
            if (confirm(msg)==true){  
                return true;  
            }else{  
                return false;  
            }  
        }  
</script> 
</head> 
<body> 
<a href="http://www.baidu.com" οnclick="return confirmd()">刪除</a> 
</body> 

</html> 



一種:

<a href="javascript:if(confirm('確實要刪除該內容嗎?'))location='http://www.google.com'">彈出窗口</a>

二種:

<script language="JavaScript">             
function delete_confirm(e) 
{
    if (event.srcElement.outerText == "刪除") 
    {
        event.returnValue = confirm("刪除是不可恢復的,你確認要刪除嗎?");
    }
}
document.onclick = delete_confirm;
</script>

<a href="Delete.aspx" onClick="delete_confirm()">刪除</a>

三種:

function delete_confirm() 
{
    if(window.confirm('你確定要取消交易嗎?')){
                 alert("確定");
                 return true;
              }else{
                 alert("取消");
                 return false;
             }
}

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


四種:

 <script language="JavaScript">             

function delete_confirm() <!--調用方法-->
{
    event.returnValue = confirm("刪除是不可恢復的,你確認要刪除嗎?");
}
</script>


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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章