469,587 Members | 2,153 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,587 developers. It's quick & easy.

Capturing all web page Events using JavaScript

2
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 5630
gits
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
bsnl
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
acoder
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:
http://www.quirksmode.org/js/events_advanced.html
http://www.howtocreate.co.uk/tutoria...ript/domevents
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 suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.