How to count clicks with javascript?

后端 未结 8 2248
予麋鹿
予麋鹿 2020-12-01 22:14

Can I count clicks on links with javascript?

8条回答
  •  被撕碎了的回忆
    2020-12-01 23:06

    Presumably you are trying to see how many links on a page a user has clicked on in order to see which ones they've visited. That is an unreliable strategy since users can visit links many different ways without clicking on them (context menu, drag to new tab, copy link location, etc.).

    If you want to know how many links they've clicked on in the current page, the answer is zero since if they click on a link they should go to another page. If you are using a listener to prevent navigation, then the same listener can also count clicks.

提交回复
热议问题