• --:)欢迎访问锋网源码(:--
  • 首页
  • RSS订阅
  • 常用软件
  • 网页模板
  • 网站运作
  • 锋网学院
  • 智能建站
  • 时代互联
  • 中国红网
  • 中资源!
  • 繁體中文

  • 学院首页
  • 新闻资讯
  • 网站运营
  • 网站开发
  • 美工设计
  • 数据库类
  • 服务器类
  • 网络应用
  • 操作系统
  • 软件教学
编程开发   认证考试   网络安全   文章搜索: 高级搜索
会员登录/控制面版 您的位置: 学院首页 >> 网站开发 >> JavaScript >> 文章内容
 

精彩推荐

 
 

本类推荐文章

 
 

本类阅读排行

  • 网页常用特效整理:初级篇
  • 学习Ajax教程,详细了解Get与..
  • 网页常用特效整理:高级篇
  • 网页图片特效小技巧
  • 网页常用特效整理:中级篇
  • AS常用代码集锦
  • 用鼠标控制滚动的菜单条!(J..
  • 用js写的一个跑马灯
  • AS常用代码集锦
  • 在网页中控制wmplayer播放器
  • ajax中文乱码解决方法
  • XMLHTTPRequest的属性和方法..
  • 关于Ajax responseText 的一..
  • 理解JavaScript函数
  • Javascript 编程规范
  • 加快图片显示(JavaScript)
  • 用javascript的正则表达式来..
  • 用js实现select对div的隐藏与..
  • 显示客户端页面执行时间的代..
  • AJAX无刷新更新数据
 
 

用鼠标控制滚动的菜单条!(JavaScript)

  • 日期:2007-06-14     人气:     出处:     作者:
  • 字体大小:
  • 小
  • 中
  • 大

第一步,将下面的代码加<head>与</head>之间

<style>
body{background-color:#FFFFFF}
A{color:Navy; text-decoration:none}
A:hover{color:red}
A:visited:{color:#808080}
TD{font-family:arial,helvetica; font-size:10pt}
#divBg{position:absolute; z-index:10; width:200; left:0; height:100; clip:rect(0,10,10,0)}
#divMenu{position:absolute; left:15; top:6; font-weight:bold}
#divArrowLeft{position:absolute; width:20; height:20; left:0; top:9}
#divArrowRight{position:absolute; width:20; height:20; top:9}
</style><script>

//Simple browsercheck
var n = (document.layers) ? 1:0;
var ie = (document.all) ? 1:0;

//The height of the menu
menuHeight=22

//Width of the arrows
arrowWidth=16

//Scroll speed: (in milliseconds, change this one and the next variable to change the speed)
scrollSpeed=20

//Pixels to scroll per timeout.
scrollPx=10

/**************************************************************************
Scrolling functions
***************************************************************************/
var tim;
var noScroll=true
function mLeft(){
if(!noScroll && oMenu.x<arrowWidth){
oMenu.moveBy(scrollPx,0)
tim=setTimeout("mLeft()",scrollSpeed)
}
}
function mRight(){
if(!noScroll && oMenu.x>-(oMenu.scrollWidth-(pageWidth))-arrowWidth){
oMenu.moveBy(-scrollPx,0)
tim=setTimeout("mRight()",scrollSpeed)
}
}
function noMove(){clearTimeout(tim); noScroll=true}
/**************************************************************************
Object part
***************************************************************************/
function makeObj(obj,nest,num){
nest=(!nest) ? '':'document.'+nest+'.'

this.css=(n) ? eval(nest+'document.'+obj):eval('document.all.'+obj+'.style')
this.evnt=(n)? eval(nest+'document.'+obj):eval(obj);
this.scrollWidth=n?this.css.document.width:this.evnt.offsetWidth
this.x=(n)? this.css.left:this.evnt.offsetLeft; this.y=(n)?
this.css.top:this.evnt.offsetTop;
this.moveBy=b_moveBy; this.moveIt=b_moveIt; this.showIt=b_showIt;this.clipTo=b_clipTo;
return this
}
function b_moveBy(x,y){this.x=this.x+x; this.y=this.y+y; this.css.left=this.x; this.css.top=this.y}
function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x; this.css.top=this.y}
function b_clipTo(t,r,b,l){
if(n){this.css.clip.top=t; this.css.clip.right=r; this.css.clip.bottom=b; this.css.clip.left=l
}else this.css.clip="rect("+t+","+r+","+b+","+l+")";
}
function b_showIt(){this.css.visibility="visible"}
/**************************************************************************
Object part end
***************************************************************************/

/**************************************************************************
Init function. Set the placements of the objects here.
***************************************************************************/
function side_init(){
//Width of the menu, Currently set to the width of the document.
//If you want the menu to be 500px wide for instance, just
//set the the pageWidth=500 in stead.
pageWidth=(n)?innerWidth:document.body.offsetWidth-20;

oBg=new makeObj('divBg')
oMenu=new makeObj('divMenu','divBg')
oArrowRight=new makeObj('divArrowRight','divBg')
//Placement
oBg.moveIt(0,0) //Main div, holds all the other divs.
oMenu.moveIt(arrowWidth,6)
oArrowRight.moveIt(pageWidth-arrowWidth,9)
//setting the width and the visible area of the links.
if(ie){ oBg.css.width=pageWidth; oBg.css.overflow="hidden"}
oBg.clipTo(0,pageWidth,menuHeight,0)
}

//executing the init function on pageload.
onload=side_init;
</script>

第二步:将下面的原代码加入<body>与</body>之间

<div id="divBg">
<div id="divMenu">
<table><tr><td nowrap>
[<a href="#">link 1</a>] ? [<a href="#">link
2</a>] ? [<a href="#">link 3</a>] ? [<a href="#">link
4</a>] ? [<a href="#">link 5</a>] ?
[<a href="#">link 6</a>] ?
[<a href="#">link 7</a>] ?
[<a href="#">link 8</a>] ?
[<a href="#">link 9</a>] ?
[<a href="#">link 10</a>] ?
[<a href="#">link 11</a>] ?
[<a href="#">link 12</a>] ?
[<a href="#">link 13</a>] ?
[<a href="#">link 14</a>] ?
[<a href="#">link 15</a>] ?
[<a href="#">link 16</a>] ?
[<a href="#">link 17</a>] ?
[<a href="#">link 18</a>] ?
[<a href="#">link 19</a>] ?
[<a href="#">link 20</a>] ?
[<a href="#">link 21</a>] ?
[<a href="#">link 22</a>] ?
[<a href="#">link 23</a>] ?
[<a href="#">link 24</a>] ?
[<a href="#">link 25</a>] ?
[<a href="#">link 26</a>] ?
[<a href="#">link 27</a>] ?
[<a href="#">link 28</a>] ?
[<a href="#">link 29</a>] ?
[<a href="#">link 30</a>]
</td></tr></table>
</div>

  <div id="divArrowLeft"><a href="javascript://" onmouseover="noScroll=false; mLeft()" onmouseout="noMove
()"><img src="images/013-r.gif" width=16 height=16 border=0></A></div>

  <div id="divArrowRight"><a href="javascript://" onmouseover="noScroll=false; mRight()" onmouseout="noMove
()"><img src="images/013-l.gif" width=16 height=16 border=0></a></div>
</div>

相关文章
  • ASP技巧教程:认识学习codepage的属性
  • asp技巧:防止被杀毒软件误删的代码
  • QQ帮你突破网吧硬盘访问限制
  • 局域网内盗用IP的安全问题
  • 邮件安全攻略:只要糖衣不要炮弹
  • 手机病毒的分类及其防范措施
  • 如何防止黒客远程盗取QQ密码
  • 始料未及,谁在控制电脑重新启动
  • 网络常见木马的手工清除方法
  • 魔高一尺 道高一丈
相关软件

  • 网友评论:
  • 查看所有评论
  • 我要发表评论
 

关于本站 | 广告联系 | 版权声明 | 网站地图 | 加入收藏 | 帮助中心 |

Copyright © 2006-2007 fwvv.net  程序支持:木翼  皖ICP备06004916号  

感谢:点击网络 联网科技 天盈信息  提供服务器及带宽赞助