ddc
联网
平面设计 画册 VI欣赏 包装 CG-插画 搜索 个人网页 Alexa排名 CSS 建站资源 下载专区 JS特效 品牌服装 服装院校 专题欣赏 SEO 图标欣赏 专题
广州网站建设 上海网站设计 网站建设 上海网站建设 网站建设 广州网站设计 虚拟主机 域名注册 虚拟主机 广州网站建设 虚拟主机 域名注册 ACG动漫家园 ACG大玩家 上海网站建设 品牌设计 网站建设
网站建设
网站建设
品牌设计
中国设计秀
中国设计秀企业频道
时代网
中资源
当前位置:网站综合首页 >> 网页JS特效 >> 图形图象类 >> 用图片代替滚动条的代码

用图片代替滚动条的代码

来源:中国设计秀    作者:    点击:180     加入收藏    发表评论
0
顶一下
<html>
<head>
<title>无标题文档</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>呵呵呵呵</p>
<p>呵呵呵呵</p>
<p>呵呵</p>
<p>呵呵</p>
<p>呵呵呵呵</p>
<p>呵呵呵呵</p>
<p>呵呵呵</p>
<p>呵呵呵呵 </p>
<p>呵呵</p>
</SPAN></SPAN>
2006-01-09 13:19:00    出处:
Google
热点文章/相关文章

音乐
嫁衣 画心 放生 天亮了 牡丹江 那滋味 擦肩而过 怀念过去 北京欢迎你 突然好想你 吻的太逼真 说好的幸福呢 坐上火车去拉萨 没有人比我更爱你
愚爱 心碎 稻香 带我走 醉赤壁 魔杰座 我还想她 明天过后 一定要爱你 等爱的玫瑰 原谅我一次 越单纯越幸福 最后一次的温柔 给我一首歌的时间
白狐 光荣 降临 下雨天 小酒窝 樱花草 恋爱新手 说唱脸谱 红色高跟鞋 寂寞才说爱 深深爱过你 爱上你是个错 即使知道要见面 不是因为寂寞才想你
城府 假如 花海 兰亭序 棉花糖 舍不得 最后一次 女人如烟 外滩十八号 我们的纪念 我们的无奈 心在跳情在烧 爱上你是我的错 爱情里没有谁对谁错
网站地图 | 关于我们 | 联系我们 | 网站建设 | 广告服务 | 版权声明 | 免责声明 | 网站公告 | 友情链接 | 留言 | 旧版入口