JS Dynamic text Scrolling example _javascript tips

Source: Internet
Author: User
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title> This is an example of dynamic JavaScript text display </title>
<script type= "Text/javascript" >
var POSITION = 50;
var DELAY = 150;
var message = "This is an example of dynamic JavaScript text display";
function Bannerobject () {
this.msg = message;
This.out = "";
This.pos = POSITION;
This.delay = delay;
this.i = 0;
This.reset = Clearmessage;
}
 
function Clearmessage () {
This.pos = POSITION;
}
var scroll = new Bannerobject ();
function Scroller () {
Scroll.out + = "";
if (scroll.pos>0)
for (scroll.i = 0; scroll.i < Scroll.pos; scroll.i++) {
Scroll.out + = "";
}
if (scroll.pos>= 0)
Scroll.out + = scroll.msg;
Else
Scroll.out = scroll.msg.substring (-scroll.pos,scroll.msg.length);
Document.noticeForm.notice.value = Scroll.out;
Scroll.out = "";
scroll.pos--;
scroll.pos--;
if (Scroll.pos <-(scroll.msg.length)) {
Scroll.reset ();
}
Window.settimeout ("Scroller ()", scroll.delay);
}
</script>
<body onload= "scroller ()" bgcolor= "#000000" link= "#C0C0C0" vlink= "#C0C0C0" alink= "#008080" text= "#C0C0C0" >
<table border= "0" cellspacing= "0" cellpadding= "0" >
&LT;TR&GT;&LT;TD width= "100%" >
<form name= "Noticeform" action= "" >
<p><input type= "text" name= "notice" size= "" style= "Background-color:rgb" (192,192,192) "/></p>"
</form>
</td></tr>
</table>
</body>

Scrolling text in the status bar
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title> This is a marquee effect of the JavaScript document-in the status bar </title>
<script type= "Text/javascript" >
var msg = "This is a marquee effect of the JavaScript document";
var interval = 100;
var spacelen = 120;
var space10 = "";
var seq = 0;
function Scroll () {
len = msg.length;
Window.status = msg.substring (0, seq + 1);
seq++;
if (seq >= len) {
seq = Spacelen;
Window.settimeout ("Scroll2 ();", interval);
}
Else
Window.settimeout ("Scroll ();", interval);
}
function Scroll2 () {
var out = "";
for (i = 1; I <= spacelen/space10.length; i++)
Out +=space10;
out = out + msg;
len = out.length;
Window.status = out.substring (seq, Len);
seq++;
if (seq >= len) {seq = 0;};
Window.settimeout ("Scroll2 ();", interval);
}
Scroll ();
</script>
<body>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.