一段js代码, 帮忙改下成函数调用
下面的代码是显示一个垂直滚动, 现在要做4个垂直滚动放在页面的不同位置
怎么把下面的代码改成函数调用?
譬如在需要滚动的地方写上自己的array后调用函数获得效果..
--------代码如下-----------------
<table width= "400 " border= "0 " align= "center " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td width= "15 " valign= "top "> <img src= "images/news.gif " alt= " " width= "11 " height= "11 " /> </td>
<td width= "64 "> 消息: </td>
<td width= "321 "> <script>
var marqueeContent=new Array(); //滚动主题
marqueeContent[0]= ' <a href= "# " target= "_blank "> 123456 </a> ';
marqueeContent[1]= ' <a href= "# " target= "_blank "> 234567 </a> ';
marqueeContent[2]= ' <a href= "# " target= "_blank "> 345678 </a> ';
marqueeContent[3]= ' <a href= "# " target= "_blank "> 456789 </a> ';
marqueeContent[4]= ' <a href= "# " target= "_blank "> 567890 </a> ';
var marqueeInterval=new Array(); //定义一些常用而且要经常用到的变量
var marqueeId=0;
var marqueeDelay=4000;
var marqueeHeight=15;
function initMarquee() {
var str=marqueeContent[0];
document.write( ' <div id=marqueeBox style= "overflow:hidden;height: '+marqueeHeight+ 'px " onmouseover= "clearInterval(marqueeInterval[0]) " onmouseout= "marqueeInterval[0]=setInterval(\ 'startMarquee()\ ',marqueeDelay) "> <div> '+str+ ' </div> </div> ');
marqueeId++;
marqueeInterval[0]=setInterval( "startMarquee() ",marqueeDelay);
}
function startMarquee() {
var str=marqueeContent[marqueeId];
marqueeId++;
if(marqueeId> =marqueeContent.length) marqueeId=0;
if(marqueeBox.childNodes.length==1) {
var nextLine=document.createElement( 'DIV ');
nextLine.innerHTML=str;
marqueeBox.appendChild(nextLine);
}
else {
marqueeBox.childNodes[0].innerHTML=str;
marqueeBox.appendChild(marqueeBox.childNodes[0]);
marqueeBox.scrollTop=0;
}
clearInterval(marqueeInterval[1]);
marqueeInterval[1]=setInterval( "scrollMarquee() ",10);
}
function scrollMarquee() {
marqueeBox.scrollTop++;
if(marqueeBox.scrollTop%marqueeHeight==marqueeHeight){
clearInterval(marqueeInterval[1]);
}
}
initMarquee();
</script> </td>
</tr>
</table>
------解决方案--------------------或者去掉.JS中数组定义那一块,把具体的内容放在调用页内: