Home  >  Article  >  Web Front-end  >  javascript实现状态栏中文字动态显示的方法_javascript技巧

javascript实现状态栏中文字动态显示的方法_javascript技巧

WBOY
WBOYOriginal
2016-05-16 15:35:531292browse

本文实例讲述了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程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn