[英]Error in JavaScript confirm message
I am new to JavaScript. 我是JavaScript新手。 I cannot find the error of this code.
我找不到此代码的错误。
<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>
help me to find my error.. 帮助我找到我的错误..
Please check with this 请检查一下
<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>
NB:The problem was with your function name I changed it confirm to confirmChk 注意:问题是你函数名我改成了确认到confirmChk
You're trying to overload "confirm" function, which is built-in function and thus your code is not working. 您正在尝试重载“确认”函数,该函数是内置函数,因此您的代码无法正常工作。 Change the name of your function from
confirm
to something else. 将函数的名称从
confirm
更改为其他名称。
try this... 尝试这个...
<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>
将函数名称更改为除确认以外的其他名称。
Use this 用这个
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>
The error happened to you cos of the reserved word confirm
. 保留字
confirm
的错误发生在您的cos上。
chek this too Reserved words in javascript http://www.javascripter.net/faq/reserved.htm 也请在javascript http://www.javascripter.net/faq/reserved.htm中 保留字样
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.