首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > vbScript >

settimeout,该如何解决

2012-02-06 
settimeoutHTML code!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.or

settimeout

HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head>    <title>ZIPBar</title></head><body style="background-color:Black"><div id="Flash"><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="640" HEIGHT="480"> <PARAM NAME=movie VALUE="Default.swf"> <PARAM NAME=quality VALUE=best> <PARAM NAME=bgcolor VALUE=#FFFFFF></OBJECT></div><script language="vbscript">'========设置Flash播放置中flash.style.position="absolute"flash.style.marginLeft="-320"flash.style.marginTop="-240"flash.style.left="50%"flash.style.top="50%"flash.style.zIndex="9999"'========初始化dim number as integernumber=1'第一个背景动画call createdbg()sub createdbg()'创建背景动画if number>200 then'如果已创造背景动画>4就不继续document.writeln("<table background='number1.gif' id='b"& number &"' style='width:118px; height:8px'><tr><td></td></tr></table>")'写入带背景动画的表格,并定义movebg(number)'移动表格函数number=number+1'已创造数+1settimeout "createdbg(i)",5'5毫秒后再创造下一个end ifend subsub movebg(id)'移动表格函数'设定表格Styledocument.getElementById("b" & id).style.position="absolute"document.getElementById("b" & id).style.left=GetX()document.getElementById("b" & id).style.top=GetY()document.getElementById("b" & id).style.marginLeft="-118"document.getElementById("b" & id).style.marginTop="-8"settimeout "movebg(id)",3100'3.1秒后再次移动表格(因为一个动画周期为3.1秒)end subfunction GetX()'随机XRnds=int(rnd*100)GetX=Rnds & "%"end functionfunction GetY()'随机YRnds=int(rnd*100)GetY=Rnds & "%"end function</script></body></html>


为什么行不通?
没有任何错误提示。
而且Flash也不居中了!
求助!

[解决办法]
try
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head>    <title>ZIPBar</title></head><body style="background-color:Black"><div id="Flash"><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="640" HEIGHT="480"> <PARAM NAME=movie VALUE="Default.swf"> <PARAM NAME=quality VALUE=best> <PARAM NAME=bgcolor VALUE=#FFFFFF></OBJECT></div><div id=ttt ></div><script language="vbscript">'========设置Flash播放置中flash.style.position="absolute"flash.style.marginLeft="-320"flash.style.marginTop="-240"flash.style.left="50%"flash.style.top="50%"flash.style.zIndex="9999"'========初始化'dim number as integernumber=1'第一个背景动画call createdbg()sub createdbg()'创建背景动画if number<=200 then'如果已创造背景动画>4就不继续ttt.innerhtml= ttt.innerhtml & "<table background='number1.gif' id='b"& number &"' style='width:118px; height:8px;border:1px red solid'><tr><td></td></tr></table>"'写入带背景动画的表格,并定义setbg(document.getElementById("b"& number))'定位表格number=number+1'已创造数+1settimeout "createdbg()",5'5毫秒后再创造下一个elsesettimeout "movebg()",3100'3.1秒后移动表格end ifend subsub movebg()'移动表格函数dim ifor i=1 to 200setbg(document.getElementById("b"& i))'定位表格函数nextsettimeout "movebg()",3100'3.1秒后再次移动表格(因为一个动画周期为3.1秒)end subsub setbg(id)'定位表格函数'设定表格Styleid.style.position="absolute"id.style.left=GetX()id.style.top=GetY()id.style.marginLeft="-118"id.style.marginTop="-8"end subfunction GetX()'随机XRnds=int(rnd*100)GetX=Rnds & "%"end functionfunction GetY()'随机YRnds=int(rnd*100)GetY=Rnds & "%"end function</script></body></html> 

热点排行