javascript之关闭弹出窗口并重定向到另一个页面
qlqwjy
阅读:90
2026-10-07 19:25:01
评论:0
我制作了一个登录注销表单,如果我想删除我的帐户,我可以。如果我按下按钮Sterge cont,将会出现一个弹出窗口,询问我是否真的要删除此帐户。如果我点击NU,帐户将不会被删除,窗口将关闭,但如果我点击DA,帐户将被删除。
我想解决的问题是,如果我点击DA,窗口将执行php删除帐户部分,然后将关闭并重定向我的页面profile.php 到 index.php?accountdeleted
请您参考如下方法:
您可以只绑定(bind)弹出事件的关闭。你可以这样做:
profile.php
<button type="button" id="delete" onclick="window.open('your_popup.php', 'popup', 'height=400, width=400, top=0, left=0,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no')">Delete</button>
然后在 your_popup.php 上:
<?php
if(isset($_POST['confirm_delete'])) {
// do you query or database delete, etc.
// at the end
echo '<script type="text/javascript">self.close(); opener.location.href = "http://localhost/citate_celebre/profil.php";</script>';
}
?>
<form method="POST" action="popup.php">
<button type="button" id="cancel_delete">Cancel</button>
<button type="submit" name="confirm_delete">Delete</button>
</form>
声明
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。



