1

Hello I have this line of code.

onClick="confirm('Are you sure you want to update the database
   to the latest version?')"><li class="navb">Update Version

But the problem is even if the user clicks cancel or no. It will still perform the function. Would appreciate any help on what I'm doing wrong. Thanks

4

2 に答える 2

7

return confirm(...)それが機能するためだけではなく、使用する必要がありますconfirm(...)

于 2013-04-08T05:31:38.193 に答える
1

関数が実際にブール値を返すことを確認します。ユーザーが [OK] をクリックした場合は true、[キャンセル] をクリックした場合は false です。
したがって、確認関数の戻り値を変数に保存し、その変数をチェックして目的の操作を実行する必要があります。

于 2013-04-08T05:32:53.373 に答える