简体   繁体   English

JavaScript删除确认框

[英]JavaScript delete confirm box

My function is something like this: 我的功能是这样的:

function delete(type, id){
    if(id){
        window.location.href = '/site/'+type+'/delete/'+id;
    }
}

I'm calling it like this: 我这样称呼它:

onclick="delete('position', <?php echo $key;?>)

Where in the function should I put the Confirm option? 在功能中我应该放置确认选项?

try this: 尝试这个:

function deleteIt(type, id)
{
    if(id && confirm('Are you sure you want to delete?'))
    {
        window.location.href = '/site/'+type+'/delete/'+id;
    }
}
function delete(type, id)
{
    if(id && (confirm('Are you sure you want to delete?')))
    {
        window.location.href = '/site/'+type+'/delete/'+id;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM