2016-12-05 22 views
-1

onclick='return confirm('Delete this comment?')'似乎不工作時不會出現。確認(「信息」)在<?php ?>

+0

我也試過在javascript中做,但結果相同 –

+0

你正在混合報價字符的方式,將無法正常工作。 – arkascha

+0

看看瀏覽器的JavaScript控制檯,當你點擊錨時,你可能會看到一個錯誤消息。 – arkascha

回答

1

您在單引號內使用單引號。使用雙引號來包裝你的代碼,而不是:

<a href='#' onclick="return confirm('Confirmation Message')">Link</a>

0

只是更改此代碼,它會工作。

echo "<a href='deleteCom.php?id=$commentID' onclick="return confirm('Delete this comment?')">Delete</a>"; 
0

您誤用了單引號和雙引號。你必須把斜線()放在引號中才能轉義。在HTML應該是這樣的:

<a href='#' onclick="return confirm('Confirmation Message')">Link</a> 

注意到,單引號應插入雙引號 「」

從您的代碼中:

echo " <a href='deleteCom.php?id=$commentID' onclick='return confirm('Delete this comment?')'>Delete</a>"; 

它應該是:

echo "<a href=\"deleteCom.php?id={$commentID}\" onclick=\"return confirm('Delete this comment?')\">Delete</a>";