I have some javascript function that is set as event listener for "click" event of window. The function detects the event target, gets its xpath in the DOM and wri