<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript onmousewheel鼠标滚轮示例</title>
<style>
#div1 { width:100px; height:100px; background-color:#}
</style>
<script>
window.onload = function(){
var oDiv = document.getElementById('div1');
oDiv.onmousewheel = fn;
if(oDiv.addEventListener){
oDiv.addEventListener('DOMMouseScroll',fn,false);
}
function fn(ev){
var ev = ev || event;
var b = true;
if(ev.wheelDelta){
b = ev.wheelDelta > ? true : false;
}else{
b = ev.detail < ? true : false;
}
if(b){
if(this.offsetHeight < ){
this.style.height = this.offsetHeight + + 'px';
};
}else{
if(this.offsetHeight > ){
this.style.height = this.offsetHeight - + 'px';
}
}
if(ev.preventDefault){
ev.preventDefault();
}
return false;
}
}
</script>
</head>
<body>
<div id="div1"></div>
</body>
</html>