Special JS Mouse Buttons

My mouse has two buttons on the sidebar, the default is Back and Forward.

What I would like to know is whether it is possible to detect clicks of these mouse buttons in JavaScript or are these special buttons similar to the "Play", "Volume Up" and "Wireless on / off" keyboards.

+4
source share
1 answer

I do not know about any specific mouse events.

You can, however, easily recognize yourself by checking the event object of the mousedown event. Full screen script: http://jsfiddle.net/dWfDL/1/show/

 var text = typeof document.body.textContent != "undefined" ? "textContent" : "innerText"; window.onmousedown = function(e){ //Inspect the `e` object, for example using a for(var i in e) loop, or: //console.log(e); var s = []; for(var i in e){ try{ if(e[i] !== null){ if(i.toUpperCase() == i) continue; //Ignore constants if(typeof e[i] == "function") continue; //Ignore functions if(e[i].parentNode) continue; //Ignore elements if(e[i] === window) continue; //Ignore Window } s.push(i + " =\t\t" + e[i]); }catch(err){s.push(i + " \tERROR reading property.")} } e.preventDefault(); s = s.join("\n") + "\n\n"; document.body[text] = s + document.body[text]; } //Double-click to wipe contents window.ondblclick = function(){ document.body[text] = ""; } 
+3
source

All Articles