我在网页中写了一段如下的JavaScript代码,在ie中能运行(能自动滚动),但是在火狐中运行就不能动了!<div id="demo" style="overflow:hidden;width:100%;color:#ffffff;">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td id="demo1" valign="top" align="center">
<table cellpadding="2" cellspacing="0" border="0" style="height: 152px">
<tr align="center">
<td> <asp:ImageButton ID="ImageButton2" runat="server"
Height="116px" ImageUrl="~/img/M_product/UFV-TC.jpg"
Width="114px" PostBackUrl="~/white.aspx" />
</td>
<td> <asp:ImageButton ID="ImageButton3" runat="server" Height="164px"
ImageUrl="~/img/M_product/UFV-2A.jpg" Width="102px" PostBackUrl="~/UFV-2A.aspx"/>
</td>
<td> <asp:ImageButton ID="ImageButton4" runat="server" Height="162px"
ImageUrl="~/img/M_product/FWK-J.jpg" Width="103px" PostBackUrl="~/FWK-J.aspx" />
</td>
<td> <asp:ImageButton ID="ImageButton5" runat="server" Height="165px"
ImageUrl="~/img/M_product/UFV-2F.jpg" Width="102px" PostBackUrl="~/UFV-2F.aspx" />
</td>
<td><asp:ImageButton ID="ImageButton6" runat="server" Height="141px"
ImageUrl="~/img/M_product/HRS.jpg" Width="150px" PostBackUrl="~/digital.aspx" />
</td>
</tr>
<tr>
<td><p align="center"><a href="white.aspx"><font size="3" color="black">
<b>UFV-TC</b></font></a></p></td>
<td><p align="center"><a href="UFV-2A.aspx"><font size="3" color="black">
<b>UFV-2A</b></font></a></p></td>
<td><p align="center"><a href="FWK-J.aspx"><font size="3" color="black">
<b>FWK-J</b></font></a></p></td>
<td><p align="center"><a href="UFV-2F.aspx"><font size="3" color="black">
<b>UFV-2F</b></font></a></p></td>
<td><p align="center"><a href="digital.aspx"><font size="3" color="black">
<b>HRS</b></font></a></p></td>
</tr>
</table>
</td>
<td id="demo2" valign="top"></td>
</tr>
</table>
</div>
<script type="text/javascript">
var speed3=25//速度数值越大速度越慢
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed3)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed3)}
</script>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td id="demo1" valign="top" align="center">
<table cellpadding="2" cellspacing="0" border="0" style="height: 152px">
<tr align="center">
<td> <asp:ImageButton ID="ImageButton2" runat="server"
Height="116px" ImageUrl="~/img/M_product/UFV-TC.jpg"
Width="114px" PostBackUrl="~/white.aspx" />
</td>
<td> <asp:ImageButton ID="ImageButton3" runat="server" Height="164px"
ImageUrl="~/img/M_product/UFV-2A.jpg" Width="102px" PostBackUrl="~/UFV-2A.aspx"/>
</td>
<td> <asp:ImageButton ID="ImageButton4" runat="server" Height="162px"
ImageUrl="~/img/M_product/FWK-J.jpg" Width="103px" PostBackUrl="~/FWK-J.aspx" />
</td>
<td> <asp:ImageButton ID="ImageButton5" runat="server" Height="165px"
ImageUrl="~/img/M_product/UFV-2F.jpg" Width="102px" PostBackUrl="~/UFV-2F.aspx" />
</td>
<td><asp:ImageButton ID="ImageButton6" runat="server" Height="141px"
ImageUrl="~/img/M_product/HRS.jpg" Width="150px" PostBackUrl="~/digital.aspx" />
</td>
</tr>
<tr>
<td><p align="center"><a href="white.aspx"><font size="3" color="black">
<b>UFV-TC</b></font></a></p></td>
<td><p align="center"><a href="UFV-2A.aspx"><font size="3" color="black">
<b>UFV-2A</b></font></a></p></td>
<td><p align="center"><a href="FWK-J.aspx"><font size="3" color="black">
<b>FWK-J</b></font></a></p></td>
<td><p align="center"><a href="UFV-2F.aspx"><font size="3" color="black">
<b>UFV-2F</b></font></a></p></td>
<td><p align="center"><a href="digital.aspx"><font size="3" color="black">
<b>HRS</b></font></a></p></td>
</tr>
</table>
</td>
<td id="demo2" valign="top"></td>
</tr>
</table>
</div>
<script type="text/javascript">
var speed3=25//速度数值越大速度越慢
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed3)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed3)}
</script>
demo用document.getElementById("demo")来替换
除了上面需要注意的地方外,还有demo.scrollLeft最好不要直接参与计算,可以写为demo.scrollLeft=parseInt(demo.scrollLeft)+1+"px";你的代码在FF3.55下貌似正常