我可以捕获用户对 <a>
的鼠标点击吗?在页面导航之前通过 jquery 标记?我想通过 ajax 调用发送它们并将它们记录在数据库中。
最佳答案
您可以通过鼠标按下或单击来捕获任何文档。也许更好的 mousedown,以免被其他点击事件阻止(通过 event.preventDefault)。
document.onmousedown = function (event) {
if (!event) {event = window.event;}
console.log("mousedown "+event.target, event);
// Post the event object here.
};
使用 jQuery:
$(document).on('mousedown', function (event) {
console.log("mousedown "+event.target, event);
// Post the event object here.
});
关于jquery - 捕获用户在网站上的所有鼠标点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40615157/