html - How can I execute JavaScript onClick of a NON-LINK? -


I have some code that is running when a user clicks anywhere in the body of a web page. I just want to run javascript if any click on a click on non-link?

Thanks / Mike

  document.body .onclick = function E) {var target = e? E.target: window.event.src element; If (target.nodeName.toLowerCase ()! == 'A') {// do something here ...}};  

Note that the event will prevent you from running the above handler. You can use event capturing to avoid this.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -