0

我的功能是这样的:

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

我这样称呼它:

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

我应该在函数的哪个位置放置“确认”选项?

4

2 回答 2

2

试试这个:

function deleteIt(type, id)
{
    if(id && confirm('Are you sure you want to delete?'))
    {
        window.location.href = '/site/'+type+'/delete/'+id;
    }
}
于 2013-03-08T09:12:01.377 回答
0
function delete(type, id)
{
    if(id && (confirm('Are you sure you want to delete?')))
    {
        window.location.href = '/site/'+type+'/delete/'+id;
    }
}
于 2013-03-08T09:14:25.190 回答