主题:  滚动菜单的代码问题

风之密码

职务:普通成员
等级:2
金币:2.0
发贴:398
#12005/1/12 11:41:42
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
</head>

<body>

<script language="javascript">
var index = 7
link = new Array(6);
text = new Array(6);
link[0] ="sample_1.htm"
link[1] ="sample_2.htm"
link[2] ="sample_3.htm"
link[3] ="sample_4.htm"
link[4] ="sample_5.htm"
link[5] ="sample_6.htm"
link[6] ="sample_7.htm"
text[0] ="菜单一"
text[1] ="菜单二"
text[2] ="菜单三"
text[3] ="菜单四"
text[4] ="菜单五"
text[5] ="菜单六"
text[6] ="菜单七"
document.write ("<marquee scrollamount='1' scrolldelay='10' direction= 'left' width='150' height='150'>");

for (i=0;i<index;i++){
document.write ("&nbsp;<img src='img/little.gif' width='12' height='12'> <a href="+link[i]+" target='_blank'>");
document.write (text[i] + "</A><br>");
}
document.write ("</marquee>")

</script>


</body>

</html>


这里面的 href="+link[i]+" 是什么意思?



bAnInE

职务:普通成员
等级:1
金币:1.0
发贴:177
#22005/1/12 11:57:35
跟text[i]一样,丛link数组中将联接地址i读出.
生成代码
&nbsp;<img src='img/little.gif' width='12' height='12'> <a href="sample_1.htm" target='_blank'>菜单一</A><br>
&nbsp;<img src='img/little.gif' width='12' height='12'> <a href="sample_2.htm" target='_blank'>菜单二</A><br>
&nbsp;<img src='img/little.gif' width='12' height='12'> <a href="sample_3.htm" target='_blank'>菜单三</A><br>
&nbsp;<img src='img/little.gif' width='12' height='12'> <a href="sample_4.htm" target='_blank'>菜单四</A><br>
&nbsp;<img src='img/little.gif' width='12' height='12'> <a href="sample_5.htm" target='_blank'>菜单五</A><br>
&nbsp;<img src='img/little.gif' width='12' height='12'> <a href="sample_6.htm" target='_blank'>菜单六</A><br>
&nbsp;<img src='img/little.gif' width='12' height='12'> <a href="sample_7.htm" target='_blank'>菜单七</A><br>



风之密码

职务:普通成员
等级:2
金币:2.0
发贴:398
#32005/1/12 13:34:32
“+”的位置可以这样写吗?
原来:
for (i=0;i<index;i++){
document.write ("&nbsp;<img src='img/little.gif' width='12' height='12'>
    <a href="+link[i]+" target='_blank'>");
document.write (text[i] + "</A><br>");
}

改为:
for (i=0;i<index;i++){
document.write ("&nbsp;<img src='img/little.gif' width='12' height='12'>
    <a href="link[i]" target='_blank'>");
document.write (+text[i] + "</A><br>");
}



不是高手

职务:普通成员
等级:3
金币:5.0
发贴:1352
#42005/1/12 14:28:50
先把要输出的东东都符给一个变量嘛,最后总的输出这个变量
JS里没你上面那种语法