?? 10-11.htm
字號:
<script language="JavaScript">
ie=document.all<!--ie的標(biāo)志-->
lshow=60
var move=10;
menuSpeed=40
var moveOnScroll=true
var tim;
var ltop;
function makeMenu(obj,nest){
this.css=eval(obj+'.style')<!--生成菜單-->
this.state=1<!--設(shè)置菜單的狀態(tài)-->
this.go=0<!--設(shè)置菜單的屬性-->
this.width=eval(obj+'.offsetWidth')<!--設(shè)置菜單寬度-->
this.left=b_getleft<!--設(shè)置菜單左邊界-->
this.obj = obj + "Object";
eval(this.obj + "=this")
}
function b_getleft(){
var gleft=eval(this.css.pixelLeft);<!--獲取菜單的左邊界-->
return gleft;
}
function moveMenu(){
if(!oMenu.state){<!--如果菜單已經(jīng)彈出-->
clearTimeout(tim)<!--清除定時器-->
mIn()<!--將菜單收回-->
}else{<!--如果菜單未彈出-->
clearTimeout(tim)<!--清除定時器-->
mOut()<!--將菜單彈出-->
}
}
function mIn(){<!--收回菜單-->
if(oMenu.left()>-oMenu.width+lshow){
oMenu.go=1<!--設(shè)置標(biāo)志位,表示菜單在運動中-->
oMenu.css.left=oMenu.left()-move<!--每次菜單的左邊界向左移動一個值-->
tim=setTimeout("mIn()",menuSpeed)<!--設(shè)置移動的速度-->
}else{
oMenu.go=0<!--設(shè)置標(biāo)志位,表示菜單不在運動中-->
oMenu.state=1<!--設(shè)置標(biāo)志位,表示菜單已經(jīng)收回-->
}
}
function mOut(){<!--彈出菜單-->
if(oMenu.left()<0){
oMenu.go=1<!--設(shè)置標(biāo)志位,表示菜單在運動中-->
oMenu.css.left=oMenu.left()+move<!--每次菜單的左邊界向右移動一個值-->
tim=setTimeout("mOut()",menuSpeed)<!--設(shè)置移動的速度-->
}else{<!--菜單彈出完畢-->
oMenu.go=0<!--設(shè)置標(biāo)志位,表示菜單不在運動中-->
oMenu.state=0<!--設(shè)置標(biāo)志位,表示菜單已經(jīng)彈出-->
}
}
function checkScrolled(){
if(!oMenu.go) oMenu.css.top=eval(scrolled)+ltop<!--確定菜單的上邊界-->
}
function menuInit(){
oMenu=new makeMenu('divMenu')<!--生成菜單-->
oMenu.css.left=-oMenu.width+lshow<!--設(shè)置菜單的左邊界-->
oMenu.css.visibility='visible'<!--將菜單設(shè)置為可視-->
}
onload=menuInit;<!--頁面載入時,直接調(diào)用函數(shù)menuInit-->
</script>
<div id="divMenu" style="position: absolute; top: 10; left: 40; width: 173; visibility: hidden; background-color: #00FFFF; height: 19"><nobr>
<a href="http://www.tom.com">TOM</a>-
<a href="http://www.sina.com">新浪</a>-
<a href="http://www.sohu.com">搜狐</a>-
<a href="http://www.nba.com">NBA</a>-
<a href="http://www.JavaScript.com">JavaScript</a>
--- <a style="background-color: #FFFF00; text-decoration: none" href="javascript://" onclick="moveMenu()">導(dǎo)航菜單</a></nobr></div>
<!--本例程實現(xiàn)了自動收縮的菜單-->
<!--收縮功能的實現(xiàn)方法-->
<!--動畫效果的速度設(shè)置-->
<!--scroll控件的交互功能-->
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -