js 拖拽翻页实现代码
blog
body{
border:0px;
margin:0px;
overflow:hidden;
background-color:transparent;
font-family:宋体;
}
.page{
position:absolute;
width:700px;
border:1px solid #999;
background-color:#000;
left:425px;
margin-left:-350px;
cursor:default;
z-index:0;
}
ul{
height:320px;
list-style:none;
margin:40px 50px 0px;
padding:0px;
}
li{
width:100%;
height:30px;
line-height:30px;
font-size:14px;
text-align:left;
border-bottom:1px dashed #999;
}
a{
text-decoration:none;
color:#999;
}
a:hover{
font-weight:bold;
}
li span{
float:right;
color:#999;
}
.tip{
display:block;
width:100%;
font-size:12px;
color:#999;
text-align:center;
margin:10px 0px 20px;
}
function id(obj){
return document.getElementById(obj);
}
var page;
var lm,mx;
var md=false;
var sh=0;
var en=false;
window.onload=function(){
page=document.getElementsByTagName("div");
if(page.length>0){
page[0].style.zIndex=2;
}
for(i=0;i第 "+(i+1)+"/"+page.length+" 页 提示:左右拖拽翻页";
page[i].id="page"+i;
page[i].i=i;
page[i].onmousedown=function(e){
if(!en){
if(!e){e=e||window.event;}
lm=this.offsetLeft;
mx=(e.pageX)?e.pageX:e.x;
this.style.cursor="w-resize";
md=true;
if(document.all){
this.setCapture();
}else{
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
}
}
}
page[i].onmousemove=function(e){
if(md){
en=true;
if(!e){e=e||window.event;}
var ex=(e.pageX)?e.pageX:e.x;
this.style.left=ex-(mx-lm)+350;
if(this.offsetLeft75){
var cu=(this.i==page.length-1)?0:this.i+1;
page[sh].style.zIndex=0;
page[cu].style.zIndex=1;
this.style.zIndex=2;
sh=cu;
}
}
}
page[i].onmouseup=function(){
this.style.cursor="default";
md=false;
if(document.all){
this.releaseCapture();
}else{
window.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP);
}
flyout(this);
}
}
}
function flyout(obj){
if(obj.offsetLeft -275 ){
obj.style.left=obj.offsetLeft + 350 - 20;
window.setTimeout("flyout(id('"+obj.id+"'));",0);
}else{
obj.style.left=-275;
obj.style.zIndex=0;
flyin(id(obj.id));
}
}
if(obj.offsetLeft>75){
if( (obj.offsetLeft + 350 + 20) 75){
if( (obj.offsetLeft + 350 - 20) > 425 ){
obj.style.left=obj.offsetLeft + 350 - 20;
window.setTimeout("flyin(id('"+obj.id+"'));",0);
}else{
obj.style.left=425;
en=false;
}
}
}
- 2009-4-9 12:35东方之珠
- 2009-4-9 12:35啊!停不住的爱人
- 2009-4-9 12:35宁静温泉
- 2009-4-9 12:35你的样子
- 2009-4-9 12:35恋曲1980
- 2009-4-9 12:35恋曲1990
- 2009-4-9 12:35恋曲2000
- 2009-4-9 12:35亚细亚的孤儿
- 2009-4-9 12:35伴侣
- 2009-4-9 12:35童年
- 2009-4-9 12:35爱的箴言
- 2009-4-9 12:35爱人同志
- 2009-4-9 12:35思念
- 2009-4-9 12:35母亲
- 2009-4-9 12:35是否
- 2009-4-9 12:35牧童
- 2009-4-9 12:35青春舞曲
- 2009-4-9 12:35蒲公英
- 2009-4-9 12:35未来的主人翁
- 2009-4-9 12:35如今才是唯一
- 2009-4-9 12:35暗恋
- 2009-4-9 12:35弹唱词
- 2009-4-9 12:35飞车
- 2009-4-9 12:35东方之珠
- 2009-4-9 12:35滚滚红尘
- 2009-4-9 12:35光阴的故事
- 2009-4-9 12:35之乎者也
- 2009-4-9 12:35现象七十二变
- 2009-4-9 12:35乡愁四韵
- 2009-4-9 12:35穿过你的黑发我的手
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]