Is it possible to use a BHO (IE8) to track which l

2019-06-13 00:04发布

问题:

Reading about BHOs and I know I can see ways in which you can track a user's navigation - however - is it possible with a BHO to identify which link was clicked by a user (for instance - if two links exist on a page in which a user can click to navigate to destination a - is it possible to determine which link was actually clicked)?

回答1:

You can sink the DISPID_HTMLELEMENTEVENTS2_ONCLICK event if you can get access to the elements (sometimes you don't such as elements in a frame in another domain)

Oh, and remember to detach your events in BeforeNavigate2.

An issue is there is no reliable way to detect a page refresh to reconnect the events or handle elements generated from scripts (Ajax).



回答2:

Yes, you can. A BHO is C++ code running inside the IE process, so it has access to all the memory and can do pretty much anything within it (doing stuff to things outside of the process is a separate topic, and is severely limited by IE).



回答3:

You've got two identical links and you want to know which was clicked?

Why not just add a unique URL parameter to each one:

<a href='mylink.html?tracking=linkA'>click me</a>
<a href='mylink.html?tracking=linkB'>click me</a>

Then your server logs will tell you which one was clicked. No need for any IE-specific hacks.