<input type="button" value="Accept Contract" class="button" onclick="if(confirm('Are you sure you want to accept this contract?')) window.open('actionurl.php');">
很简单,为什么它不起作用?它根本不会弹出确认框。
<input type="button" value="Accept Contract" class="button" onclick="if(confirm('Are you sure you want to accept this contract?')) window.open('actionurl.php');">
很简单,为什么它不起作用?它根本不会弹出确认框。
我宁愿为此创建一个单独的函数。
<script>
function bla()
{
if(confirm('Are you sure you want to accept this contract?'))
window.open('actionurl.php');
}
</script>
<input type="button" value="Accept Contract" class="button" onclick="bla();">
它在这里运作良好。但是,试试这个:
<script>
document.getElementById('confirmButton').onclick = function(){
if(confirm('Are you sure you want to accept this contract?'))
window.open('actionurl.php');
}
</script>
<input type="button" value="Accept Contract" class="button" id="confirmButton">
测试它并且工作正常,自己检查它