Home > Web Front-end > HTML Tutorial > Very cool drag paging (JS CSS)_html/css_WEB-ITnose

Very cool drag paging (JS CSS)_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:45:13
Original
1154 people have browsed it



拖动分页




<script> <br> function id(obj){ <br>  return document.getElementById(obj); <br> } <br> var page; <br> var lm,mx; <br> var md=false; <br> var sh=0; <br> var en=false; <br> window.onload=function(){ <br>  page=document.getElementsByTagName("div"); <br>  if(page.length>0){ <br>   page[0].style.zIndex=2; <br>  } <br> // http://www.codefans.net <br>  for(i=0;i<page.length;i ){ <br />   page[i].className="page"; <br />   page[i].innerHTML ="<span class=tip>第 " (i 1) "/" page.length " 页 提示:左右拖拽翻页</span>"; <br>   page[i].id="page" i; <br>   page[i].i=i; <br>   page[i].onmousedown=function(e){ <br>    if(!en){ <br>     if(!e){e=e||window.event;} <br>     lm=this.offsetLeft; <br>     mx=(e.pageX)?e.pageX:e.x; <br>     this.style.cursor="w-resize"; <br>     md=true; <br>     if(document.all){ <br>      this.setCapture(); <br>     }else{ <br>      window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP); <br>     } <br>    } <br>   } <br>   page[i].onmousemove=function(e){ <br>    if(md){ <br>     en=true; <br>     if(!e){e=e||window.event;} <br>     var ex=(e.pageX)?e.pageX:e.x; <br>     this.style.left=ex-(mx-lm) 350; <br>     if(this.offsetLeft<75){ <br />      var cu=(this.i==0)?page.length-1:this.i-1; <br />      page[sh].style.zIndex=0; <br />      page[cu].style.zIndex=1; <br />      this.style.zIndex=2; <br />      sh=cu; <br />     } <br /> <br /> <br /> if(this.offsetLeft>75){ <br> var cu=(this.i==page.length-1)?0:this.i 1; <br> page[sh].style.zIndex=0; <br> page[cu].style.zIndex=1; <br> this.style.zIndex=2; <br> sh=cu; <br>     } <br>    } <br>   } <br>   page[i].onmouseup=function(){ <br>    this.style.cursor="default"; <br>    md=false; <br>    if(document.all){ <br>     this.releaseCapture(); <br>    }else{ <br>     window.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP); <br>    } <br>    flyout(this); <br>   } <br>  } <br> } <br> <br> <br> function flyout(obj){ <br>  if(obj.offsetLeft<75){ <br />   if(  (obj.offsetLeft 350 - 20) > -275 ){ <br>    obj.style.left=obj.offsetLeft 350 - 20; <br>    window.setTimeout("flyout(id('" obj.id "'));",0); <br>   }else{ <br>    obj.style.left=-275; <br>    obj.style.zIndex=0; <br>    flyin(id(obj.id)); <br>   } <br>  } <br> <br> <br>  if(obj.offsetLeft>75){ <br>   if(  (obj.offsetLeft + 350 + 20) < 1125 ){ <br /> obj.style.left=obj.offsetLeft + 350 + 20; <br /> window.setTimeout("flyout(id('"+obj.id+"'));",0); <br /> }else{ <br /> obj.style.left=1125; <br /> obj.style.zIndex=0; <br /> flyin(id(obj.id)); <br /> } <br /> } <br /> } <br /> function flyin(obj){ <br /> if(obj.offsetLeft<75){ <br /> if( (obj.offsetLeft + 350 + 20) < 425 ){ <br /> obj.style.left=obj.offsetLeft + 350 + 20; <br /> window.setTimeout("flyin(id('"+obj.id+"'));",0); <br /> }else{ <br /> obj.style.left=425; <br /> en=false; <br /> } <br /> } <br /> if(obj.offsetLeft>75){ <br>   if(  (obj.offsetLeft + 350 - 20) > 425  ){ <br>    obj.style.left=obj.offsetLeft + 350 - 20; <br>    window.setTimeout("flyin(id('"+obj.id+"'));",0); <br>   }else{ <br>    obj.style.left=425; <br>    en=false; <br>   } <br>  } <br> } <br> </script>


 


 


 



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template