Ehsan
Ehsan

Reputation: 4474

Listening to the events that are happening in a page?

I'm trying to recognize the events that are happening in a page. For example, the page is loaded is one event then the user clicks a link it is another event or open a dropdown box and so on, so here I'm looking for all these events? any idea on how I can monitor the events that are happening in a html page?

Upvotes: 0

Views: 40

Answers (2)

Jonathan
Jonathan

Reputation: 9151

JQuery and Prototype have excellent cross-browser solutions for that.

JQ click example:

$('#foo').bind('click', function() {
  alert('User clicked on "foo."');
});

JQ DOM-ready example (page has loaded):

$(document).ready(function() {
  $('#foo').bind('click', function(event) {
    alert('The mouse cursor is at ('
      + event.pageX + ', ' + event.pageY + ')');
  });
});

Upvotes: 1

maximkou
maximkou

Reputation: 5332

You can read about events here:

Events: http://w3schools.com/jsref/dom_obj_event.asp

Using: http://www.w3.org/wiki/Handling_events_with_JavaScript

Upvotes: 0

Related Questions