我正在使用来确认内容的删除。 我已经使用js确认用户删除内容..但如果用户取消确认对话框,它应该重定向..但相反,页面加载整个脚本,然后重定向!Javascript正在加载脚本的其余部分也是
脚本放在这里......
if (confirm("Are you sure you want to delete??"))
alert("deletion successful");
else
history.go(-1);
alert("unwanted alert");
这种不必要的警报还显示,当我点击确认在对话框中取消..
编辑.. 实际上整个代码是这样这..也许这将清楚地看到我的问题是什么
<html>
<script>
if (!confirm("Are you sure you want to delete??"))
history.go(-1);
</script>
<?php
require_once "config.php";
$query= 'DELETE FROM `sess` WHERE `sid` ='.$_GET['bid'];
if ($conn->query($query) === TRUE) {?>
<script>
alert("deletion successful");
window.location.replace("../index.php");
</script>
<?php
} else {?>
<script>
alert("unable to delete!");
window.location.replace("../index.php");
</script>
<?php }?>
</html>
你是什么意思由'页面加载整个脚本'?而不需要的警报,它应该是“else”块的一部分吗? –
你可以修理缩进吗? – usethedeathstar