我是JavaScript新手。我找不到此代码的错误。
<td class="paid">
<a href="invoice.php?id=<?php echo $invoice_result['id']; ?>" onclick="confirm()">
<img src="images/view_3.gif"/>
</a>
</td>
<script type="text/javascript">
function confirm() {
if (confirm("Do you realy want do delete this vehicle?")) {
return true;
} else {
return false;
}
}
</script>
帮我找到错误..
答案 0 :(得分:3)
请查看
<td class="paid"><a href="invoice.php?id=<?php echo $invoice_result['id']; ?>" onclick="confirmChk()"><img src="images/view_3.gif"/></a></td>
<script type="text/javascript">
function confirmChk(){
if(confirm("Do you realy want do delete this vehicle?")){
return true;
}
else{
return false;
}
}
</script>
注意:问题在于您的功能名称我将其确认更改为 confirmChk
答案 1 :(得分:1)
您正在尝试重载“确认”功能,这是内置功能,因此您的代码无效。将您的函数名称从confirm
更改为其他内容。
答案 2 :(得分:1)
试试这个......
<td class="paid">
<span onclick="return confirm('Do you realy want do delete this vehicle?')">
<a href="invoice.php?id=<?php echo $invoice_result['id']; ?>"><img src="images/view_3.gif"/></a>
</span>
</td>
答案 3 :(得分:0)
将您的功能名称更改为除确认之外的其他名称。
答案 4 :(得分:0)
使用此
onClick="return confirm('Do you realy want do delete this vehicle?');"
...
<td class="paid"><a href="invoice.php?id=<?php echo $invoice_result['id']; ?>"
onClick="return confirm('Do you realy want do delete this vehicle?');">
<img src="images/view_3.gif"/></a></td>
保留字confirm
发生了错误。
这也是Reserved words in javascript http://www.javascripter.net/faq/reserved.htm