[问题求助] “tab2”为空或不是对象
我做的一个网页,主要功能是不间断的滚动图片。为什么他老是报错,说:'tab2' 为空或不是对象?请高手帮忙。谢谢!
下面为Html代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<script>
<!--
var speed=8;
var tab=document.getElementById("demo");
var tab1=document.getElementById("demo1");
var tab2=document.getElementById("demo2");
tab2.innerHTML=tab1.innerHTML;
function Marquee(){
if(tab2.offsetWidth-tab.scrollLeft<=0)
tab.scrollLeft-=tab1.offsetWidth
else{
tab.scrollLeft++;
}
}
var MyMar=setInterval(Marquee,speed);
tab.onmouseover=function() {clearInterval(MyMar)};
tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)};
-->
</script><div style="margin-top:20px;">
<div id="scroll_div" style="overflow: hidden; WIDTH: 1008px;" align=center>
<table width="1024" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="1000" id="scroll_begin">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr><td width="3%"><TABLE border=0 width=106 height=108>
<TBODY>
<TR>
<TD width=119>
<DIV align=center>
<P><IMG style="WIDTH: 120px; HEIGHT: 90px" border=0 align=middle src="http://files.展示板.jpg" width=120 height=130><FONT size=2> 2009研讨会的展示板</FONT></P>
</DIV></TD></TR></TBODY></TABLE></td><td width="3%"><TABLE border=0 width=106 height=108>
<TBODY>
<TR>
<TD width=119>
<DIV align=center>
<P><IMG style="WIDTH: 120px; HEIGHT: 90px" border=0 align=middle src="http://files.费敏锐教授.JPG" width=120 height=130><FONT size=2> 费敏锐现场致辞</FONT></P>
</DIV></TD></TR></TBODY></TABLE></td><td width="3%"><TABLE border=0 width=106 height=108>
<TBODY>
<TR>
<TD width=119>
<DIV align=center>
<P><IMG style="WIDTH: 120px; HEIGHT: 90px" border=0 align=middle src="http://files.上海大学学术委员会主席方明伦教授.JPG" width=120 height=130><FONT size=2> 方明伦致贺词</FONT></P>
</DIV></TD></TR></TBODY></TABLE></td><td width="3%"><TABLE border=0 width=106 height=108>
<TBODY>
<TR>
<TD width=119>
<DIV align=center>
<P><IMG style="WIDTH: 120px; HEIGHT: 90px" border=0 align=middle src="http://files.刀协邢敏理事长致贺词.JPG" width=120 height=130><FONT size=2> 邢敏致贺词</FONT></P>
</DIV></TD></TR></TBODY></TABLE></td><td width="3%"><TABLE border=0 width=106 height=108>
<TBODY>
<TR>
<TD width=119>
<DIV align=center>
<P><IMG style="WIDTH: 120px; HEIGHT: 90px" border=0 align=middle src="http://files.揭牌仪式.jpg" width=120 height=130><FONT size=2> 2009研讨会揭牌仪式</FONT></P>
</DIV></TD></TR></TBODY></TABLE></td><td width="3%"><TABLE border=0 width=106 height=108>
<TBODY>
<TR>
<TD width=119>
<DIV align=center>
<P><IMG style="WIDTH: 120px; HEIGHT: 90px" border=0 align=middle src="http://files.昌河铃木副总经理谢晓林教授.jpg" width=120 height=130><FONT size=2> 谢晓林</FONT></P>
</DIV></TD></TR></TBODY></TABLE></td></tr>
<tr></tr>
</table>
</td>
<td width="12" id="scroll_end"></td>
</tr>
</table>
</div></div>
<script>
var speed1=40
var scroll_end = document.getElementById("scroll_end");
var scroll_div = document.getElementById("scroll_div");
scroll_end.innerHTML=scroll_begin.innerHTML
function Marquee1(){
if(scroll_end.offsetWidth-scroll_div.scrollLeft<=0)
scroll_div.scrollLeft-=scroll_begin.offsetWidth
else{
scroll_div.scrollLeft++
}
}
var MyMar1=setInterval(Marquee1,speed1)
scroll_div.onmouseover=function() {clearInterval(MyMar1)}
scroll_div.onmouseout=function() {MyMar1=setInterval(Marquee1,speed1)}
</script>
</body>
</html>