I have a grid of divs which represents a map. I want to be able to generate click event on any of the div as I click with my mouse. I have used following code snippet with no success though I get a true return value:
var fireOnThis = document.getElementById('someID');
var evObj = document.createEvent('MouseEvents');
evObj.initEvent( 'click', true, true );
fireOnThis.dispatchEvent(evObj);
I know no click is being generated because when I click with actual mouse the div gets highlighted.
Just a side question: Is it possible that one could distinguished between actual mouse generated clicks and ones generated via javascript itself and block the later ones ?(I know it sounds logically wrong but I dont know much JS so maybe.... )
Some background: I am doing this for an online gaming website where I want to automate the routine tasks by writing an extension for chrome....this part is for content script.
Edit: Perhaps I am looking at problem the wrong way..... perhaps in actual, the div is not listening for the click event, the reason div doesn't get selected in actual even when the event gets fired.....
New Question:
given the event (i.e., click on a particular div) can I tell which listener/element received that event ?