我有一个将用户发送到页面的按钮,但首先要求用户确认,但它无法正常工作,我该如何解决?谢谢
<input class="cancel" type="button" value="Cancel" onclick="window.location.href='<?php bloginfo('home'); ?>';return confirm('Are you sure you want to delete your post?');" />
最佳答案
试试这个:
<input class="cancel" type="button" value="Cancel" onclick="if (confirm('Are you sure you want to delete your post?')) window.location.href='http://www.google.com';" />
关于javascript - 同时使用 window.location 和 return confirm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5021110/