FED

©FrontEndDev.org
2015 - 2024
web@2.22.0 api@2.20.0

变色导航菜单的响应问题

问题报错是Uncaught ReferenceError: filters is not defined 当鼠标经过菜单时,并不会进行颜色变换,显示上述报错,通过百度发现普遍存在这个问题, 那么,是哪里的问题?应该怎么改?谢

<!DOCTYPE html>
<html>
<head>
	<title>Example</title>
</head>
<body>

<style> 
/*先把这个myMenu的样式放到css里*/ 
.myMenu td{
	font-size:12px;font-family:verdana,arial;
	font-weight: bolder;
	color: #ffffff; 
	border: 1px solid #336699;
	filter:blendtrans(duration=0.5);
	cursor: hand;
	text-align: center;
}
</style>

<script>

//把事件动作绑定到菜单上
function addMenu(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='#FEBD20';                     //鼠标移上去时的背景颜色
                    style.border='1px solid #ffffff';              //边框
                    style.color='black';                             //文字颜色
                    filters[0].play();
                }
            }
            onmouseout=function(){
                with (this){
                    filters[0].apply();
                    style.background='#336699';                      //鼠标离开时的背景颜色
                    style.border='1px solid #336699';               //边框
                    style.color='#ffffff';                            //文字颜色
                    filters[0].play();
                }
            }
        }
    }
}
</script>

<table class="myMenu" id="menuTb1" width="500" cellpadding="1" cellspacing="4" border="0" bgcolor="#000000" align="center"> 网站介绍 开发文档 下载软件 开源管理 网站服务 </table>

<script>
	addMenu(menuTb1); //在上面这个table结束的地方执行事件行动的绑定,这里的这个menuTb1就是那个table的id
</script>

</body>
</html>