Reputation: 277
I am working on mouse tracking application. i will give a small piece of code to my user, He will paste that piece of code into his footer, and the recording will start for his website. whenever any user visits his website, i save the source of the visited page, and track all the mouse movements, scrolling, typing and clicking. if he clicks on a link, then i save the source of that page again and its mouse movement and so on. my user can view the recordings and use activity of each session using his control panel.
i have been stuck in the following case.
If user clicks on any div, span, p, img, checkbox, dropdown, radio etc and there is any jquery effect is associated with it. if there is any id or name then i can trigger the click event onto that id or name object during playback. But if i dont have any id or name then i cant trigger the click event.
i am saving the x,y position also. but there is the problem of accuracy during playback.
that why i want to track the function called for click event on the above mentioned elements and call that function directly during playback.
is there any way to track which "user defined function" is being called onClick in javascript or jquery without any debugger tool. Please note that i dont know the name of any function associated with each element. i can only track the click using the following code:
$(window).mousedown( function(e) {
mouseTracker.clickState = true;
console.log( "id:" + e.target.id + " name:" + e.target.name );
mouseTracker.clickObject = e.target.id + ":" + e.target.name;
}).mouseup( function() {
mouseTracker.clickObject = ':';
mouseTracker.clickState = false;
});
Can anyone please help.
Regards,
Upvotes: 1
Views: 2192
Reputation: 495
I think you are looking for this:
The code bellow traces every click performed on the DOM
$(document.documentElement).on('click', function(e){
//e.target will output the clicked element
//$._data( element, "events" ) will find any events attached to this element
console.log($._data( e.target, "events" ));
});
NOTE: This answer uses jQuery, I'm assuming that it's loaded.
Upvotes: 1