tags:

views:

40

answers:

1

how do i detect which event I had clicked, suing javascript ? this includes when clicking on the Browser Back button too.

+1  A: 

You can detect clicks inside the page with a simple click event handler:

document.onclick= function(event) {
    // Compensate for IE<9's non-standard event model
    //
    if (event===undefined) event= window.event;
    var target= 'target' in event? event.target : event.srcElement;

    alert('clicked on '+target.tagName);
};

It is impossible for web-page script detect clicks outside the page such as the back button and other browser chrome, for good security reasons. You would have to be part of a browser extension to do this.

bobince
+1 Bobince, you give great answers to not so great questions!
alex