我需要捕獲用戶單擊我的聊天應用程序上的鏈接時發生的事件。我正在使用IE11。檢測聊天窗口中的鏈接點擊事件
當某個鏈接可以動態添加到聊天框(即用戶在任何給定時間發送「www.google.com」消息)時,是否有方法捕獲用戶單擊該鏈接?
我一直在使用onbeforeunload的方式,雖然這檢測到瀏覽器關閉事件,它不會檢測到鏈接點擊事件,我不知道爲什麼,所以我在想,一個jQuery解決方案,檢查頁面上的鏈接
$('a').on('click', function(){
//track clicked link here
return true; //to allow following the link this is the default behavior no need to add
return false; //prevent default behavior
});
您是否試圖檢測像$('。chat-window a')這樣的點擊事件? – kdureidy