最好先复制下来用IE打开看一下效果!我想链接,但是效果不能丢
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
/* 先把这个 xmenu 的样式放到css里 */
.xmenu td{font-size:14px;font-family:verdana,arial;font-weight:bolder;color:#ffffff;border:1px solid #4f4f4f;background:#4f4f4f;filter:blendtrans(duration=0.5);cursor:hand;text-align:center;}
</style></head>
<body bgcolor =black><script>
/* 
这是把事件动作绑定到菜单上的函数
*/
function attachXMenu(objid){
var tds=objid.getElementsByTagName('td');
for(var i=0;i<tds.length;i++){
with(tds[i]){
onmouseover=function(){
with(this){
filters[0].apply();
style.background='red'; //这是鼠标移上去时的背景颜色
style.border='1px solid #ff0000'; //边框
style.color='#4f4f4f'; //文字颜色
filters[0].play();
}
}
onmouseout=function(){
with(this){
filters[0].apply();
style.background='#4f4f4f'; //这是鼠标离开时的背景颜色
style.border='1px solid #4f4f4f'; //边框
style.color='#ffffff'; //文字颜色
filters[0].play();
}
}
}
}
}
</script><!--菜单从这里开始, 注意要把class设置成和css里相同的, 还要为它设一个id-->
<table class="xmenu" id="xmenu0" width="1010" cellpadding="1" cellspacing="4" border="0" bgcolor="#4f4f4f" align="center" >
<tr>
<td>我的首页</td>
<td>公司简介</td>
<td>产品中心</td>
<td>服务支持</td>
                  <td>驱动下载</td>
<td>友情链接</td>
<td>联系我们</td>
                  <td>BBS论坛</td>

                  <td><iframe src="http://s.117.org.cn/clock/#color:ffffff;font-size:9pt" width=200 height=20 frameborder=0 scrolling=no allowtransparency=true></iframe></td>
</tr>
</table><script>attachXMenu(xmenu0); </script>//在上面这个table结束的地方执行事件动作的绑定, 这里的这个xmenu0就是那个table的id
</body>
</html>

解决方案 »

  1.   


    <script>
    /*
    这是把事件动作绑定到菜单上的函数
    */
    function attachXMenu(objid){
    var tds=objid.getElementsByTagName('td');
    //urls 是连接的url数组
    var urls = ["http://www.baidu.com","url2","url3","url4","url5","url6","url7","url8"];
    for(var i=0;i <tds.length;i++){with(tds[i]){
    tds[i].onclick= (function(j){
    return function(){
    window.location.href = urls[j];
    }
    })(i)
    onmouseover=function(){
    with(this){
    filters[0].apply();
    style.background='red'; //这是鼠标移上去时的背景颜色
    style.border='1px solid #ff0000'; //边框
    style.color='#4f4f4f'; //文字颜色
    filters[0].play();}
    }
    onmouseout=function(){
    with(this){
    filters[0].apply();
    style.background='#4f4f4f'; //这是鼠标离开时的背景颜色
    style.border='1px solid #4f4f4f'; //边框
    style.color='#ffffff'; //文字颜色
    filters[0].play();
    }
    }
    }
    }
    }
    </script>
      

  2.   

    你要学会用jQuery等等这样的js库,这种常见问题,往往别人都解决过了,都会用某种js库的插件方式分享出来。