我有一个将用户发送到页面的按钮,但首先要求用户确认,但是它无法正常工作,我该如何解决?感谢
<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?');" />
答案 0 :(得分:8)
试试这个:
<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';" />
答案 1 :(得分:4)
编写新功能
void redirect(url) {
if (confirm('Are you sure you want to delete your post?')) {
window.location.href=url;
}
return false;
}
然后从你的onclick
onclick="redirect('<?php bloginfo('home'); ?>');"
答案 2 :(得分:1)
转动命令。您将离开当前页面,然后进行确认。那不行。
if (confirm(...)) window.location.href='....'