点击大图上一张下一张滑过左右图的滑过事件

 /**
    **点击大图事件
    *
    */     
    function getEvent(){
      if(document.all){
        return window.event;
      }
      func=getEvent.caller;
      while(func!=null){
       var arg0=func.arguments[0];
       if(arg0){
        if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.                 stopPropagation)){
             return arg0;
           }
         }
       func=func.caller;
       }
       return null;
     }
    function Get_mouse_pos(obj){
      var event=getEvent();
      if(navigator.appName=='Microsoft Internet Explorer'){
        return event.offsetX;
      }else if(navigator.appName=='Netscape'){
          return event.pageX-obj.offsetLeft;
      }
    }
    
    
    function turnover(obj){
      var move_x=Get_mouse_pos(obj);
      var img_width=document.getElementById("imgID").offsetWidth;
      var show_width=img_width;
      if(move_x >= show_width/2){
        obj.style.cursor="URL(../images/next.cur),auto";
        obj.title='下一张';
      obj.onclick=function(){
       $('#rightbt').click();//点击右半边图片的事件
      };                       
      }else{
      obj.style.cursor="URL(../images/pre.cur),auto";
         obj.title='上一张';
      obj.onclick=function(){
       $('#leftbt').click();//点击左半边图片的事件
       }
       }
    }
    
    $("#imgID").mousemove(function(){//imgID图片的id
        turnover(this);
    })

原文地址:https://www.cnblogs.com/dearxinli/p/2834296.html