function click anywhere javascript

JavaScript
document.body.addEventListener('click', fn, true); 
Source

Also in JavaScript: