15.Nov 2006
Mausrad mit Javascript abfragen


function handle( delta ) { alert( delta ); }

function mousewheel( event ) {

  var delta = 0;

  if ( !event )
    event = window.event;
  
  if ( event.wheelDelta ) { // IE
    delta = event.wheelDelta / 120;
 
    if ( window.opera ) // Opera
      delta = -delta;
  } else if ( event.detail ) { // Mozilla
    delta = -event.detail / 3;
  }
 
  if ( delta ) handle(delta);

  if ( event.preventDefault )
    event.preventDefault();
  
  event.returnValue = false;
}

if (window.addEventListener) // Mozilla
  window.addEventListener('DOMMouseScroll', mousewheel, false);
	
window.onmousewheel = document.onmousewheel = mousewheel;