好东西,自己留着备用,用来自动化过各种验证码!

function slide (id,classname, offsetX) {
	var slider
	if(classname == 'none'){
		slider = document.getElementById(id);
	}else{
		slider = document.getElementsByClassName(classname)[0];
	}

    var rect = slider.getBoundingClientRect(),
        x0 = rect.x || rect.left,
        y0 = rect.y || rect.top,
        x1 = x0 + offsetX, 
        y1 = y0;
    var mousedown = document.createEvent('MouseEvents');
    mousedown.initMouseEvent('mousedown', true, true, window, 0, x0, y0, x0, y0, false, false, false, false, 0, null);
    slider.dispatchEvent(mousedown);  
 
    var mousemove = document.createEvent('MouseEvents');
    mousemove.initMouseEvent('mousemove', true, true, window, 0, x1, y1, x1, y1, false, false, false, false, 0, null);
    slider.dispatchEvent(mousemove);

    var mouseout = document.createEvent('MouseEvents');
    mouseout.initMouseEvent('mouseout', true, true, window, 0, x1, y1, x1, y1, false, false, false, false, 0, null);
    slider.dispatchEvent(mouseout);
}
slide('none','nc_iconfont btn_slide', 300);//id