asp学习网: 首页 >> javascript教程 >> Firefox onmousewheel

Firefox onmousewheel

发现 firefox 没有 mousewheel 事件,google 一下,汗!很多人相信 Firefox 根本没有这个事件,甚至有人居然用监听 onscroll 事件解决的问题。好不容易在一个新闻组里面发现一点线索,试着写了一小段代码,测试成功 :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
</head>
<body>
</body>

<script>
var n=0;
function mwEvent(e)
{
if (!e) e = window.event;

if ( e.wheelDelta <= 0 || e.detail > 0) { n++; }
else { n--; }
window.status=n;
}
if(document.attachEvent){
document.attachEvent("onmousewheel",mwEvent);
}else{
window.addEventListener("DOMMouseScroll", mwEvent, false);
}
</script>
</html>

原文:http://www.mmommo.com/?id=68

from:asp学习网/title:Firefox onmousewheel/ time:2007-2-24 21:08:53

本文主题Firefox onmousewheel

asp教程 ©2006-2007 aspxuexi.com | 关于站点 | 版权隐私 | 站内搜索
复制或者翻版 请于夜间进行