>
设为首页
>
收藏本站
>
最新电影
首页
运营资讯
今日英语
图形图像
计算机技术
Asp编程
网站结构化
资源共享
休闲娱乐
访问新站
您现在的位置:
首页
=>
后台技术
=>
脚本特效
=>
页面特效
订阅本栏目
使用span模拟滚动条效果
时间: 2008-08-13 23:48:00 阅读次数:2604
使用span模拟滚动条效果
<html> <head> <title>网页特效|www.ffasp.com 飞飞Asp乐园|---模拟滚动条</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <STYLE type=text/css> #scrollerContent {POSITION: absolute} body {font-size:9pt;color:#660000;text-decoration: none} </STYLE> <script> var upH = 13;//向上的箭头的高度 var upW = 9; //向上的箭头的宽度 var downH = 13;//向下的箭头的高度 var downW = 9;//向下的箭头的宽度 var dragH = 26; //滚动条的高度 var dragW = 9; //滚动条的宽度 var scrollH =68; //滚动体的高度 var speed =9; //滚动的速度 var dom = document.getElementById ? true:false; var nn4 = document.layers ? true:false; var ie4 = document.all ? true:false; var mouseY; var mouseX; var clickUp = false; var clickDown = false; var clickDrag = false; var clickAbove = false; var clickBelow = false; var timer = setTimeout("",500); var upL; var upT; var downL; var downT; var dragL; var dragT; var rulerL; var rulerT; var contentT; var contentH; var contentClipH; var scrollLength; var startY; function down(e){ if((document.layers && e.which!=1) || (document.all && event.button!=1)) return true; getMouse(e); startY = (mouseY - dragT); if(mouseX >= upL && (mouseX <= (upL + upW)) && mouseY >= upT && (mouseY <= (upT + upH))){ clickUp = true; return scrollUp(); } else if(mouseX >= downL && (mouseX <= (downL + downW)) && mouseY >= downT && (mouseY <= (downT + downH))){ clickDown = true; return scrollDown(); } else if(mouseX >= dragL && (mouseX <= (dragL + dragW)) && mouseY >= dragT && (mouseY <= (dragT + dragH))){ clickDrag = true; return false; } else if(mouseX >= dragL && (mouseX <= (dragL + dragW)) && mouseY >= rulerT && (mouseY <= (rulerT + scrollH))){ if(mouseY < dragT){ clickAbove = true; clickUp = true; return scrollUp(); } else{ clickBelow = true; clickDown = true; return scrollDown(); } } else{ return true; } } function move(e){ if(clickDrag && contentH > contentClipH){ getMouse(e); dragT = (mouseY - startY); if(dragT < (rulerT)) dragT = rulerT; if(dragT > (rulerT + scrollH - dragH)) dragT = (rulerT + scrollH - dragH); contentT = ((dragT - rulerT)*(1/scrollLength)); contentT = eval('-' + contentT); moveTo(); if(ie4) return false; } } function up(){ clearTimeout(timer); clickUp = false; clickDown = false; clickDrag = false; clickAbove = false; clickBelow = false; return true; } function getT(){ if(ie4) contentT = document.all.scrollerContent.style.pixelTop; else if(nn4) contentT = document.scrollerContentClip.document.scrollerContent.top; else if(dom) contentT = parseInt(document.getElementById("scrollerContent").style.top); } function getMouse(e){ if(ie4){ mouseY = event.clientY + document.body.scrollTop; mouseX = event.clientX + document.body.scrollLeft; } else if(nn4 || dom){ mouseY = e.pageY; mouseX = e.pageX; } } function moveTo(){ if(ie4){ document.all.scrollerContent.style.top = contentT; document.all.ruler.style.top = dragT; document.all.drag.style.top = dragT; } else if(nn4){ document.scrollerContentClip.document.scrollerContent.top = contentT; document.ruler.top = dragT; document.drag.top = dragT; } else if(dom){ document.getElementById("scrollerContent").style.top = contentT + "px"; document.getElementById("drag").style.top = dragT + "px"; document.getElementById("ruler").style.top = dragT + "px"; } } function scrollUp(){ getT(); if(clickAbove){ if(dragT <= (mouseY-(dragH/2))) return up(); } if(clickUp){ if(contentT < 0){ dragT = dragT - (speed*scrollLength); if(dragT < (rulerT)) dragT = rulerT; contentT = contentT + speed; if(contentT > 0) contentT = 0; moveTo(); timer = setTimeout("scrollUp()",25); } } return false; } function scrollDown(){ getT(); if(clickBelow){ if(dragT >= (mouseY-(dragH/2))) return up(); } if(clickDown){ if(contentT > -(contentH - contentClipH)){ dragT = dragT + (speed*scrollLength); if(dragT > (rulerT + scrollH - dragH)) dragT = (rulerT + scrollH - dragH); contentT = contentT - speed; if(contentT < -(contentH - contentClipH)) contentT = -(contentH - contentClipH); moveTo(); timer = setTimeout("scrollDown()",25); } } return false; } function reloadPage(){ location.reload(); } function eventLoader(){ if(ie4){ upL = document.all.up.style.pixelLeft; upT = document.all.up.style.pixelTop; downL = document.all.down.style.pixelLeft; downT = document.all.down.style.pixelTop; dragL = document.all.drag.style.pixelLeft; dragT = document.all.drag.style.pixelTop; rulerT = document.all.ruler.style.pixelTop; contentH = parseInt(document.all.scrollerContent.scrollHeight); contentClipH = parseInt(document.all.scrollerContentClip.style.height); } else if(nn4){ upL = document.up.left; upT = document.up.top; downL = document.down.left; downT = document.down.top; dragL = document.drag.left; dragT = document.drag.top; rulerT = document.ruler.top; contentH = document.scrollerContentClip.document.scrollerContent.clip.bottom; contentClipH = document.scrollerContentClip.clip.bottom; } else if(dom){ upL = parseInt(document.getElementById("up").style.left); upT = parseInt(document.getElementById("up").style.top); downL = parseInt(document.getElementById("down").style.left); downT = parseInt(document.getElementById("down").style.top); dragL = parseInt(document.getElementById("drag").style.left); dragT = parseInt(document.getElementById("drag").style.top); rulerT = parseInt(document.getElementById("ruler").style.top); contentH = parseInt(document.getElementById("scrollerContent").offsetHeight); contentClipH = parseInt(document.getElementById("scrollerContentClip").offsetHeight); document.getElementById("scrollerContent").style.top = 0 + "px"; } scrollLength = ((scrollH-dragH)/(contentH-contentClipH)); if(nn4){ document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP); window.onresize = reloadPage; } document.onmousedown = down; document.onmousemove = move; document.onmouseup = up; } </script></head> <BODY onload="eventLoader()"> <SPAN id=drag style="LEFT: 203px;POSITION: absolute; TOP: 116px"><IMG height=26 src="slider.gif" width=9 border=1></SPAN> <SPAN id=ruler style="TOP: 116px"></SPAN> <SPAN id=up style="LEFT: 203px; POSITION: absolute; TOP: 100px"><IMG height=13 alt="" src="scrollup.gif" width=9 border=1></SPAN> <SPAN id=down style="LEFT: 203px; POSITION: absolute; TOP: 186px"><IMG height=13 alt="" src="scrolldown.gif" width=9 border=1></SPAN> <SPAN id=scrollerContentClip style=" LEFT: 100; VISIBILITY: visible; OVERFLOW: hidden; WIDTH: 100; CLIP: rect(0px 140px 194px 0px); POSITION: absolute; TOP: 100; HEIGHT: 100;border:#CC6600 1px solid"><SPAN id=scrollerContent style="width: 100; height: 100"> <p>ddd</p> <p>d</p> <p>d</p> <p>d</p> <p> </p> <p>dd</p> <p>d</p> <p> </p> <p>d</p> <p>d</p> <p> </p> <p>d</p> </SPAN></SPAN> </body> </html>
提示:您可以先修改部分代码再运行
飞飞Asp技术~乐园
站内搜索
:
标题
内容
下一篇
表单验证 文本框 只能输入汉字
上一篇
无法拦截与屏蔽的网页漂浮图片广告代码 完全自定义 全屏飘动
本栏目最新
栏目最新列表
使用JS对select动态添加options操作 [IE&Fi
符合标准的对联广告代码
使用js/javascript制作特殊的字符效果
图片上传预览,可显示文件大小,宽、高
文件上传前台控制检测预览程序 v0.6
网站优化策划
栏目最新列表
增加网站外链的快速方法
网站上线前必做的30个检查
新的友情链接参考标准(没有google的PR情况
优化Google的AdSense广告的五个工具
王通讲SEO八大基础
站点最新
站点最新列表
微博推广的一些技巧
xhEditor v1.1.7 发布,
收集的一些轻量级非常实
50个新鲜兼容最新版本的
javascript中cookie的设
Excel中出现#VALUE!、#D
jquery插件:飞飞表情插件
十个使用HTML5开发的精彩
支持HTML5的浏览器有哪些
飞妮莫属:漫画:如何写出
历史最热10条信息
MIME介绍 及
[
1
] [
2
] [
3
]
巧用Google和迅雷来下载
Transact SQL 常
[
1
] [
2
]
VIA Rhine II Fast Ethe
电脑常用端
[
1
] [
2
] [
3
]
Do you get a kick out
十道羊皮卷 欣赏+mp3版+
每日一句:A friend and
每日一句:Theres no tu
经典__悟透JavaScript
伟哥博客
西安房产
123最新电影
三四六四
关于站点
|
免责声明
|
联系站长
|
网站地图
|
陕ICP备07002804号
WEB技术QQ交流群:72840059
©2007 ffasp.com. 版权所有