JS簡單菜單
<head>
<title>list menu test</title>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
z-index:1;
background-color: #00FF00;
visibility:hidden;
}
-->
</style>
</head>
<body>
<div id="Layer1" onMouseOut="ShowDiv(false);" onMouseOver="ShowDiv(true);"><span id="ceshi"></span></div>
<table width="96" height="139" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<td id="tr0" onMouseOver="ShowMessager(this,true)" onMouseOut="ShowMessager(this,false)">list menu 0 </td>
</tr>
<tr>
<td id="tr1" onMouseOver="ShowMessager(this,true)" onMouseOut="ShowMessager(this,false)">list menu 1 </td>
</tr>
<tr>
<td id="tr2" onMouseOver="ShowMessager(this,true)" onMouseOut="ShowMessager(this,false)">list menu 2 </td>
</tr>
</table>
<script>
var intervalID=0;
var Action_Tag=false;
function ShowMessager(objid,action_tag)
{
getAbsPoint(objid,objid.clientHeight,objid.clientWidth);
Action_Tag=action_tag;
}
function getAbsPoint(e,h,w)
{
var x = e.offsetLeft, y = e.offsetTop;
while(e=e.offsetParent)
{
x += e.offsetLeft;
y += e.offsetTop;
}
ceshi.innerHTML=y+":"+x;
Layer1.style.top =y+h;
Layer1.style.left=x+w;
Layer1.style.visibility='visible';
}
function ShowDiv(action_tag)
{
Action_Tag=action_tag;
}
function Timer_start()
{
intervalID=window.setInterval("Timer_action()",1000);
}
function Timer_action()
{
if(Action_Tag==false)
{
//Timer_stop();
//timeCnt=0;
Layer1.style.visibility='hidden';
}
else
{
//timeCnt+=1;
//Layer1.style.visibility='visible';
//ceshi.innerHTML+="¥";
}
}
/*function Timer_stop()
{
window.clearInterval(intervalID);
} */
//intervalID=window.setInterval("Timer_action()",1000);
Timer_start();
</script>
</body>
</html>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.