我的功能是这样的:
function delete(type, id){
if(id){
window.location.href = '/site/'+type+'/delete/'+id;
}
}
我这样称呼它:
onclick="delete('position', <?php echo $key;?>)
我应该在函数中的哪个位置放置确认选项?
答案 0 :(得分:2)
试试这个:
function deleteIt(type, id)
{
if(id && confirm('Are you sure you want to delete?'))
{
window.location.href = '/site/'+type+'/delete/'+id;
}
}
答案 1 :(得分:0)
function delete(type, id)
{
if(id && (confirm('Are you sure you want to delete?')))
{
window.location.href = '/site/'+type+'/delete/'+id;
}
}