本文实例讲述了javascript实现状态栏中文字动态显示的方法。分享给大家供大家参考,具体如下:
<script> var child = window.open("information.html","_blank","width=200,height=200,toolbar=no"); function closeChild(){ if(!child.closed){ child.close(); } } //设置间隔1秒钟,调用一次scroll() setInterval("scroll()",100) var space_num = 0; var dir = 1; //文本开始从左向右移动 function scroll(){ var str_space = ""; space_num = space_num + 1*dir; //如果空格数大于40 或者 小于0时 if(space_num > 40 || space_num <= 0){ dir = dir * (-1); } //空格数自增 for(var i=0; i<space_num; i++){ str_space += " "; } //在文字前空格数变换 window.status = str_space + "welcome to study"; } </script> <body onunload="closeChild()"> </body>
希望本文所述对大家JavaScript程序设计有所帮助。