function ischinese(s){//判断是否为汉字 var ret=true; for(var i=0;i<s.length;i++) ret=ret && (s.charCodeAt(i)>=10000); return ret; } var msg = "这是一个跑马灯效果的JavaScript文档"; var interval = 100; var seq = 0; var blankstr = ""; var len = msg.length; function scrool(){ window.status = msg.substring(0,seq+1); seq++; if( seq >= len){ seq = 0; scrool2(); }else window.setTimeout("scrool();",interval); } function scrool2(){ if(ischinese(msg.substring(seq,seq+1))) blankstr = blankstr+" "; else blankstr = blankstr+" "; var str = blankstr+msg.substring(seq,len); window.status = str seq++; if(seq > len){ seq = 0; blankstr = ""; scrool(); } else window.setTimeout("scrool2();",interval); } scrool();