我有一个2个不同链接的确认框。如果我只使用其中一个(意味着删除其他功能),它可以正常工作,但当我有两个功能时,两个都不起作用,它只是直接到链接的URL。
这是html
function myReset() {
if (confirm("This will reset all counters for this campaign back to 0. \nAre you sure?") == true) {
return true;
} else {
return false;
}
}
function myDel() {
if (confirm("This will completely delete this campaign. Any traffic to it will be lost.\nAre you sure?") == true) {
return true;
} else {
return false;
}
}
<a href="campaignmanager?todo=reset&id=$myrow[id]" alt="Reset This Campaign" title="Reset This Campaign" onclick="return myReset()">
<img src="images/icon-reset.png" border="0">
</a>
<a href="campaignmanager?todo=delete&id=$myrow[id]" alt="Delete This Campaign" title="Delete This Campaign" onclick="return myDel()">
<img src="images/icon-delete.png" border="0">
</a>
任何帮助都会很棒。
答案 0 :(得分:2)
- Edit-- 只需将确认内联。
<a href="campaignmanager?todo=reset&id=$myrow[id]" alt="Reset This Campaign" title="Reset This Campaign" onclick="return confirm('This will reset all counters for this campaign back to 0. \nAre you sure?')"><img src="images/icon-reset.png" border="0"></a> <a href="campaignmanager?todo=delete&id=$myrow[id]" alt="Delete This Campaign" title="Delete This Campaign" onclick="return confirm('This will completely delete this campaign. Any traffic to it will be lost.\nAre you sure?')"><img src="images/icon-delete.png" border="0"></a>