鼠标脱动,IE和FF不兼容
FF下报错 EventObject.setCapture is not a functionvar EventObject = 0, Old_X, New_X;
function button_down(event){//拖动按钮按下事件
event = event ? event :(window.event ? window.event : null);
EventObject = event.srcElement ? event.srcElement : event.target;
Old_X = event.clientX;
EventObject.setCapture();
}
function button_move(event){//拖动按钮移动事件
if(EventObject){
New_X = event.clientX;
try{
var MovePels = EventObject.style.pixelLeft+New_X-Old_X;
var MaxBound = document.getElementById(EventObject.id+"Box").offsetWidth-EventObject.offsetWidth;
}
catch(e){}
if(EventObject && MovePels <= MaxBound && MovePels >= 0){
EventObject.style.pixelLeft += New_X-Old_X;
Old_X = New_X;
}
}
}
function button_up(){//拖动按钮松开事件
if(EventObject){
EventObject.releaseCapture();
EventObject = 0;
}
}