我有這樣的鏈接。防止鏈接,確認,然後轉到位置jquery
<a href="delete.php?id=1" class="delete">Delete</a>
如果用戶點擊它。確認應該彈出,然後只有當用戶點擊是,它應該轉到實際的網址。
我知道,這樣可以防止默認行爲
function show_confirm()
{
var r=confirm("Are you sure you want to delete?");
if (r==true) { **//what to do here?!!** }
}
$('.delete').click(function(event) {
event.preventDefault();
show_confirm()
});
但我怎麼繼續該鏈接或確認後發送一個ajax後該鏈接?
好了,所以..有一個陷阱,以這種方式,這將是如果用戶打算在新選項卡中打開鏈接,則不會查看該用戶是否打開了該鏈接,甚至可能有一個目標=「_ somespecificwindow」或target =「_ blank」.. :) –
如果您在新tab_中打開或中間鼠標點擊鏈接,你會通過確認,使用'