Home >Web Front-end >JS Tutorial >JavaScript news ticker example code_javascript skills

JavaScript news ticker example code_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:24:031282browse

The example in this article shares with you the marquee effect code implemented in javascript, which implements functions such as news announcements. The following is a marquee example for your reference. I hope it can be helpful to friends in need.

Operation rendering:

The code example is as follows:

<!DOCTYPE html> 
<html> 
<head> 
<meta charset="gb2312"> 
<title>javascript新闻跑马灯效果</title>
</head>
<script type="text/javascript">
var msg="脚本之家欢迎您http://www.jb51.net";
var interval = 100;
var space10="";
var seq=0;
function Scroll() 
{
 document.tmForm.tmText.value = msg.substring(seq, msg.length) + space10 + msg.substring(0, msg.length);
 seq++;
 seq++;
 if(seq >msg.length) 
 {
  seq=0 
 }
 window.setTimeout("Scroll();", interval )
} 
</script>
<body onload="Scroll();" >
<center>
<form name="tmForm">
 <input type="text" name="tmText" size="45">
</form>
</center>
</body>
</body>
</html>

I hope this article will be helpful to everyone in learning javascript programming.

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