当前位置: 代码迷 >> JavaScript >> JS任务栏滚动效果有关问题
  详细解决方案

JS任务栏滚动效果有关问题

热度:87   发布时间:2012-03-30 17:32:09.0
JS任务栏滚动效果问题
<!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> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title> 无标题文档 </title> 
</head> 
<script language="javascript">
function time()
{
var str = "******123456*******";
var strlen = str.length;
var inc = 0;
var show ="";
if (inc >= strlen)
{
inc=0;
}
else
{
inc++;
}
show = str.substr(inc,strlen-inc);
//window.status = show;
if (inc>0)
{
show+=str.substr(0,inc-1);
window.status = show;
}
//setTimeout(time(),500);
}
window.setInterval(time(),20000);
</script>
<body> 
</body> 
</html> 


哪里有错呢 为何无法移动呢 就这样改 不然我怕看不懂

------解决方案--------------------
这个样子了



<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title> 无标题文档 </title>
</head>
<script language="javascript">
var str="******123456*******";

var strlen=str.length;

var inc=0;

var show="";
function time()
{



if(inc>=strlen)
{

inc=0;


}
else 
{

inc++;


}
show=str.substr(inc,strlen-inc);

//window.status = show; 
if(inc>0)
{

show+=str.substr(0,inc-1);

window.status=show;


}
//setTimeout(time(),500); 

}
window.setInterval("time()",200);

</script>
<body>
</body>
</html>
------解决方案--------------------
<script type=text/javascript>
<!--
var inc = 0;
function time(){
var str = "******123456******";
var strlen = str.length;
var show ="";
if (inc > = strlen) inc=0;
else {
inc++;
}
show = str.substr(inc,strlen-inc); 
//window.status = show;
if (inc> 0)
{
show+=str.substr(0,inc-1);
window.status = show;
}
//setTimeout(time(),500);
}
window.setInterval(time,500); 

好像还得注意">="中间没空格
  相关解决方案