471,887 Members | 1,435 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,887 software developers and data experts.

Capturing all web page Events using JavaScript

Hi, my company has a bunch of web pages on which they want to record every DOM event(mouse movement, clicks etc), these pages were written in past and now with minimal editing I need to add listener to capture these events.
Can someone provide an easy and effective way to do this (may be addition of eventlistener at Body tag to capture all bubbled up events, but i am not sure if it will work when stopPropagation method is called by some eventlistener in the chain).
Thanks to every reader of this question
Feb 20 '09 #1
3 5673
5,390 Expert Mod 4TB
you may try to add listeners to the document like this (for FF):

Expand|Select|Wrap|Line Numbers
  1. document.addEventListener('click', function(e) { 
  2.     alert(e.type + ' - ' + e.target.nodeName) 
  3. }, true);
so as you see you would need to register an additional listener for every event-type you want to observe. have a look here for further information. may be that helps?

kind regards

PS: btw. i changed the threadTitle because JAVA != JavaScript.
Feb 21 '09 #2
Thanks gits
I think handling stopPropagation would be the biggest challenge here (specially in IE), because if a child node stops bubbling of event then I suppose that document level eventhandler will not be called.
I am also looking for a way to dispatch the events (for a replay of actions on a given web page), from one browser-platform type to another.

Please let me know, If there's any site/book that might help in this
Feb 22 '09 #3
16,027 Expert Mod 8TB
If stopPropagation was called, that means the event didn't take place, so there's no need to record it. Note, though, that IE uses a different model (attachEvent, cancelBubble, etc.) See the following links:
Feb 23 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by jerrygarciuh | last post: by
10 posts views Thread by Andrew | last post: by
1 post views Thread by louise raisbeck | last post: by
2 posts views Thread by jbigham | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.