使用js实现推拉式菜单


<style>#Cai1 {
BACKGROUND-COLOR: #336699;
BORDER-BOTTOM: white 2px outset;
BORDER-LEFT: white 2px outset;
BORDER-RIGHT: white 2px outset;
BORDER-TOP: white 2px outset; LEFT: 0px;
POSITION: absolute; TOP: 70px; VISIBILITY: hidden;
WIDTH: 200px; layer-background-color: lightblue
}
</style>
<script language="javascript">
<!--
function menuIn() {                         // 菜单隐藏
clearTimeout(out_ID)                        // 清除定时器
if( menu.pixelLeft > menuW*-1+20 ) {
 menu.pixelLeft -= 2                 // 菜单位置递减
 in_ID = setTimeout("menuIn()", 1)   // 启动定时器
}
}

function menuOut() {                        // 菜单出现
clearTimeout(in_ID)                         // 清除定时器
if( menu.pixelLeft < 0) {
 menu.pixelLeft += 2                 // 菜单位置递增
 out_ID = setTimeout("menuOut()", 1) // 启动定时器
}
}


function cOver() {
clearTimeout(F_out)
F_over = setTimeout("menuOut()", 10)
}


function cOut() {
clearTimeout(F_over)
F_out = setTimeout("menuIn()", 10)
}


function init() {
menu = Cai1.style
menuW = Cai1.offsetWidth
Cai1.style.pixelLeft = menuW*-1+20             // 设置菜单初始位置
Cai1.onmouseover = cOver                       // 鼠标划过时调用cOver函数
Cai1.onmouseout = cOut                         // 鼠标离开时调用cOut函数
Cai1.style.visibility = "visible"              // 显示图层
}
F_over=F_out=in_ID=out_ID=null
//-->
</script>
</head>
<body οnlοad="init()">
<div id="Cai1">
<table border="0">
<tr>
 <td width=40>&nbsp;</td><td align="center"><font style="COLOR: #ffffff">菜单</font></td>
</tr>
<tr>
 <td width=40>&nbsp;</td><td><a href="http://www.sina.com.cn"><font color="#cccccc" size=2>新浪网</font></a></td>
</tr>
</tr>
 <td width=40>&nbsp;</td><td><a href="http://www.sohu.com"><font color="#cccccc" size=2>搜狐</font></a></td>
</tr>
<tr>
 <td width=40>&nbsp;</td><td><a href="http://www.163.com"><font color="#cccccc" size=2>网易</font></a></td>
</tr>
</table>
</div>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值