===================================================================
<html>
<head>
<title> 炫彩变色菜单</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body><style>
/* 先把这个 xmenu 的样式放到css里 */
.xmenu td{font-size:12px;font-family:verdana,arial;font-weight:bolder;color:#ffffff;border:1px solid #336699;background:#336699;filter:blendtrans(duration=0.5);cursor:hand;text-align:center;}
</style><script>
/*
http://lexrus.blueidea.com这是把事件动作绑定到菜单上的函数
*/
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='#66CCFF'; //这是鼠标移上去时的背景颜色
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><!--菜单从这里开始, 注意要把class设置成和css里相同的, 还要为它设一个id-->
<table class="xmenu" id="xmenu0" width="500" cellpadding="1" cellspacing="4" border="0" bgcolor="#336699" align="center">
<tr>
<td>My</td>
<td>Name</td>
<td>Is</td>
<td>LeX</td>
<td>Rus</td>
<td>!!!</td>
</tr>
</table><script>attachXMenu(xmenu0); //在上面这个table结束的地方执行事件动作的绑定, 这里的这个xmenu0就是那个table的id</script>
</body>
</html>
================================================================
谁能给我详细介绍一下这段代码每一部分的意思和作用,尤其是filters[0].apply();这一句中filters和apply都是什么方法活函数,有什么用?另外给我讲讲with这个语法是什么,可以做什么
<html>
<head>
<title> 炫彩变色菜单</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body><style>
/* 先把这个 xmenu 的样式放到css里 */
.xmenu td{font-size:12px;font-family:verdana,arial;font-weight:bolder;color:#ffffff;border:1px solid #336699;background:#336699;filter:blendtrans(duration=0.5);cursor:hand;text-align:center;}
</style><script>
/*
http://lexrus.blueidea.com这是把事件动作绑定到菜单上的函数
*/
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='#66CCFF'; //这是鼠标移上去时的背景颜色
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><!--菜单从这里开始, 注意要把class设置成和css里相同的, 还要为它设一个id-->
<table class="xmenu" id="xmenu0" width="500" cellpadding="1" cellspacing="4" border="0" bgcolor="#336699" align="center">
<tr>
<td>My</td>
<td>Name</td>
<td>Is</td>
<td>LeX</td>
<td>Rus</td>
<td>!!!</td>
</tr>
</table><script>attachXMenu(xmenu0); //在上面这个table结束的地方执行事件动作的绑定, 这里的这个xmenu0就是那个table的id</script>
</body>
</html>
================================================================
谁能给我详细介绍一下这段代码每一部分的意思和作用,尤其是filters[0].apply();这一句中filters和apply都是什么方法活函数,有什么用?另外给我讲讲with这个语法是什么,可以做什么
为语句设定默认对象。with (object)
statements参数object新的默认对象。statements一个或多个语句,object 是该语句的默认对象。说明with 语句通常用来缩短特定情形下必须写的代码量。在下面的例子中,请注意 Math 的重复使用:x = Math.cos(3 * Math.PI) + Math.sin(Math.LN10) y = Math.tan(14 * Math.E)
当使用 with 语句时,代码变得更短且更易读:with (Math){ x = cos(3 * PI) + sin (LN10) y = tan(14 * E)}
filters[0].play();//标签为name = filters的第一个调用play方法没有什么特殊的含义