自动收缩的菜单
1 <html>
2 <head>
3 <title>网页特效|Linkweb.cn/Js|---自动收缩的菜单</title>
4 </head><body link="#000000">
5 <!--将以下代码加入HTML的<Body></Body>之间-->
6
7 <script language="JavaScript1.2">
8 ie=document.all?1:0
9 n=document.layers?1:0
10 lshow=60
11 var move=10;
12 menuSpeed=40
13 var moveOnScroll=true
14 var tim;
15 var ltop;
16 function makeMenu(obj,nest){
17 nest=(!nest) ? '':'document.'+nest+'.'
18 this.css=(n) ? eval(nest+'document.'+obj):eval(obj+'.style')
19 this.state=1
20 this.go=0
21 this.width=n?this.css.document.width:eval(obj+'.offsetWidth')
22 this.left=b_getleft
23 this.obj = obj + "Object"; eval(this.obj + "=this")
24 }
25 function b_getleft(){
26 var gleft=(n) ? eval(this.css.left):eval(this.css.pixelLeft);
27 return gleft;
28 }
29 function moveMenu(){
30 if(!oMenu.state){
31 clearTimeout(tim)
32 mIn()
33 }else{
34 clearTimeout(tim)
35 mOut()
36 }
37 }
38 function mIn(){
39 if(oMenu.left()>-oMenu.width+lshow){
40 oMenu.go=1
41 oMenu.css.left=oMenu.left()-move
42 tim=setTimeout("mIn()",menuSpeed)
43 }else{
44 oMenu.go=0
45 oMenu.state=1
46 }
47 }
48 function mOut(){
49 if(oMenu.left()<0){
50 oMenu.go=1
51 oMenu.css.left=oMenu.left()+move
52 tim=setTimeout("mOut()",menuSpeed)
53 }else{
54 oMenu.go=0
55 oMenu.state=0
56 }
57 }
58 function checkScrolled(){
59 if(!oMenu.go) oMenu.css.top=eval(scrolled)+ltop
60 if(n) setTimeout('checkScrolled()',30)
61 }
62 function menuInit(){
63 oMenu=new makeMenu('divMenu')
64 scrolled=n?"window.pageYOffset":"document.body.scrollTop"
65 oMenu.css.left=-oMenu.width+lshow
66 ltop=(n)?oMenu.css.top:oMenu.css.pixelTop;
67 oMenu.css.visibility='visible'
68 if(moveOnScroll) ie?window.onscroll=checkScrolled:checkScrolled();
69 }
70 onload=menuInit;
71 </script>
72 <div id="divMenu" style="position: absolute; top: 163; left: 35; width: 173; visibility: hidden; background-color: ccccff; height: 19"><nobr>
73 <a href="#">音乐视听</a>-
74 <a href="#">天空下载</a>-
75 <a href="#">游戏世界</a>-
76 <a href="#">超蓝空间</a>-
77 <a href="#">中国软件</a>-
78 -- <a style="background-color: blue; text-decoration: none" href="javascript://" onclick="moveMenu()">导航菜单</a></nobr></div>
79 </body></html>
2 <head>
3 <title>网页特效|Linkweb.cn/Js|---自动收缩的菜单</title>
4 </head><body link="#000000">
5 <!--将以下代码加入HTML的<Body></Body>之间-->
6
7 <script language="JavaScript1.2">
8 ie=document.all?1:0
9 n=document.layers?1:0
10 lshow=60
11 var move=10;
12 menuSpeed=40
13 var moveOnScroll=true
14 var tim;
15 var ltop;
16 function makeMenu(obj,nest){
17 nest=(!nest) ? '':'document.'+nest+'.'
18 this.css=(n) ? eval(nest+'document.'+obj):eval(obj+'.style')
19 this.state=1
20 this.go=0
21 this.width=n?this.css.document.width:eval(obj+'.offsetWidth')
22 this.left=b_getleft
23 this.obj = obj + "Object"; eval(this.obj + "=this")
24 }
25 function b_getleft(){
26 var gleft=(n) ? eval(this.css.left):eval(this.css.pixelLeft);
27 return gleft;
28 }
29 function moveMenu(){
30 if(!oMenu.state){
31 clearTimeout(tim)
32 mIn()
33 }else{
34 clearTimeout(tim)
35 mOut()
36 }
37 }
38 function mIn(){
39 if(oMenu.left()>-oMenu.width+lshow){
40 oMenu.go=1
41 oMenu.css.left=oMenu.left()-move
42 tim=setTimeout("mIn()",menuSpeed)
43 }else{
44 oMenu.go=0
45 oMenu.state=1
46 }
47 }
48 function mOut(){
49 if(oMenu.left()<0){
50 oMenu.go=1
51 oMenu.css.left=oMenu.left()+move
52 tim=setTimeout("mOut()",menuSpeed)
53 }else{
54 oMenu.go=0
55 oMenu.state=0
56 }
57 }
58 function checkScrolled(){
59 if(!oMenu.go) oMenu.css.top=eval(scrolled)+ltop
60 if(n) setTimeout('checkScrolled()',30)
61 }
62 function menuInit(){
63 oMenu=new makeMenu('divMenu')
64 scrolled=n?"window.pageYOffset":"document.body.scrollTop"
65 oMenu.css.left=-oMenu.width+lshow
66 ltop=(n)?oMenu.css.top:oMenu.css.pixelTop;
67 oMenu.css.visibility='visible'
68 if(moveOnScroll) ie?window.onscroll=checkScrolled:checkScrolled();
69 }
70 onload=menuInit;
71 </script>
72 <div id="divMenu" style="position: absolute; top: 163; left: 35; width: 173; visibility: hidden; background-color: ccccff; height: 19"><nobr>
73 <a href="#">音乐视听</a>-
74 <a href="#">天空下载</a>-
75 <a href="#">游戏世界</a>-
76 <a href="#">超蓝空间</a>-
77 <a href="#">中国软件</a>-
78 -- <a style="background-color: blue; text-decoration: none" href="javascript://" onclick="moveMenu()">导航菜单</a></nobr></div>
79 </body></html>