繁体   English   中英

使用window.location并一起返回确认

[英]Using window.location and return confirm together

我有这个按钮,将用户发送到页面,但首先要求用户确认,但它无法正常工作,我该如何解决? 谢谢

<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';" />

写一个新功能

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'); ?>');"

转动命令。 您将离开当前页面, 然后进行确认。 那不行。

if (confirm(...))  window.location.href='....'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM