参照网上的资源作了简化修改,具体代码不做详细解释,大家一看就明白:

<html>

<head>

<script language="JavaScript1.2">

<!--

//定义菜单内容

var menucontents='<a href="http://www.google.com">www.google.com</a> | <a href="http://www.gsuo.com">www.gsuo.com</a> | <a href="http://www.baidu.com">www.baidu.com</a> | <a href="http://www.sina.com.cn">www.sina.com.cn</a>'

-->

</script>

</head>

 

<body onload="initmenu(testmenu,menucontents);">

<table border="1" cellspacing="0" cellpadding="0">

       <tr>

              <td width="200">

                     test1

              </td>

              <td width="200">         

                     test2

              </td>     

       </tr>

       <tr>

              <td id="testmenu" colspan="2" valign="middle">&nbsp;           

              </td>     

       </tr>

</table>

</body>

<script language="JavaScript1.2">

<!--

//配置菜单宽度

var menuwidth=300

 

//定义滚动速度(1-10),越大越快

var scrollspeed=6

 

//==========以下不需要修改============//

 

var actualwidth=0

 

function initmenu(menuContainer,menuContent){      

       menuContainer.innerHTML='<table border="0" cellspacing="0" cellpadding="0"><tr><td valign="middle"><a href=# style="TEXT-DECORATION:none;" onMouseover="moveright()" onMouseout="clearTimeout(righttime)">&lt;&lt;&lt;</a>&nbsp;</td><td valign="top">'

                                                 +'<span style="position:relative;width:'+menuwidth+';">'

                                                 +'<span style="position:absolute;width:'+menuwidth+';clip:rect(0 '+menuwidth+' auto 0)">'

                                                 +'<span id="menu" style="position:absolute;left:0;top:0">'

                                                 +'<nobr>'+menuContent+'</nobr>'

                                                 +'</span></span></span>'

                                                 +'</td><td valign="middle">&nbsp;<a href="#" style="TEXT-DECORATION:none;" onMouseover="moveleft()" onMouseout="clearTimeout(lefttime)">&gt;&gt;&gt;</a></td></tr></table>';                             

       actualwidth=menu.offsetWidth;

}

 

function moveleft(){     

       if (document.all&&menu.style.pixelLeft>(menuwidth-actualwidth))

              menu.style.pixelLeft-=scrollspeed

      

       lefttime=setTimeout("moveleft()",50)

}

 

function moveright(){

       if (document.all&&menu.style.pixelLeft<0)

              menu.style.pixelLeft+=scrollspeed

      

       righttime=setTimeout("moveright()",50)

}

-->

</script>

</html>

 

posted on 2006-03-08 21:19 野草 阅读(745) 评论(0)  编辑  收藏 所属分类: html/js

只有注册用户登录后才能发表评论。


网站导航: