自己写了个获取鼠标坐标的例子:Util=new Object();
//鼠标的坐标
Util.getMouseCoordinate=function(e){
if(e.pageX||e.pageX){
return {x:e.pageX, y:e.pageY};
}
return {x:e.clientX,y:e.clientY}
}
Util.showPixl=function(ev){
ev=ev||window.event;
var mousePox=Util.getMouseCoordinate(ev);
document.getElementById("pix").value=mousePox.x+","+mousePox.y;
}
window.onload=function(){
document.onmousemove=Util.showPixl
}问题:在FF中showPixl函数的参数是什么

解决方案 »

  1.   

    但是我在函数中没有看到event啊,window.event只在IE下有效
      

  2.   

    FF下浏览器自动调用你的回调函数,并传入Event对象。
    Util.showPixl=function(ev){
       alert(ev);
    }以上代码在FF下应该显示[object MouseEvent]
    在IE中无效然后
    ev=ev||window.event;
    这句话代表如果系统没有传入Event对象,则用window.event前面一半代表FF,后面一半支持IE
      

  3.   

    document.onmousemove=Util.showPixl楼主的这句决定了参数是什么,DOM标准的FF下的事件发生时自动将事件对象传给事件处理函数(也就是showPixl),而IE则不会传递任何事件对象,需要用window.event得到。所以FF下事件处理函数的第一个参数永远是事件对象(你不用管它到底是什么),所以ev = ev || window.event;就一定能得到事件对象了。楼主可以打印出来看看是什么...
      

  4.   

    <input onchange="if ! (this.value.match(/(0\.\d{1,4}|[0,1](\.0)?)/)){alert('aa')}" size="30" type="text" />
    为什么上面代码无效?