我正在使用來確認內容的刪除。 我已經使用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