Skip to content Skip to sidebar Skip to footer

How To Capture *any* Element Where The User Clicked With Javascript?

This is a follow up to this question. The idea is to get where the user clicked in a Firefox browser through a JavaScript. Starting from the named question, the following JavaScrip

Solution 1:

I hired a freelancer to finish the script. I was pretty close, but since im absolutely new in Javascript, it would have taken me too long to figure it out. I was needing to use 'onmousedown' instead of 'onclick' as event. The resulting script is as follows:

varDocElements = document.getElementsByTagName('*');for(var i = 0; i < DocElements.length; i++){DocElements[i].onmousedown = functionclicked(MyElement){var target = (MyElement.target) ? MyElement.target : MyElement.srcElement;var e = document.createElement('a'); e.setAttribute('id','myUniqueID'); e.setAttribute('value', this); target.appendChild(e);};}

I hope this is useful for someone else in the future.

Post a Comment for "How To Capture *any* Element Where The User Clicked With Javascript?"