An example of a scrolling message : Text HTML « HTML « JavaScript DHTML

Home
JavaScript DHTML
1.Ajax Layer
2.Data Type
3.Date Time
4.Development
5.Document
6.Dojo toolkit
7.Event
8.Event onMethod
9.Ext JS
10.Form Control
11.GUI Components
12.HTML
13.Javascript Collections
14.Javascript Objects
15.Javascript Properties
16.jQuery
17.Language Basics
18.Mochkit
19.Mootools
20.Node Operation
21.Object Oriented
22.Page Components
23.Rico
24.Scriptaculous
25.Security
26.SmartClient
27.Style Layout
28.Table
29.Utilities
30.Window Browser
31.YUI Library
JavaScript DHTML » HTML » Text HTML 
An example of a scrolling message

/*
Javascript Essentials
by Jason J. Manger

Publisher: Mcgraw-Hill Osborne Media; 

ISBN: 0078822343
*/
<!--
  Program 10-6
-->
<html>
<head>
<script language="JavaScript">
<!--
 var timerId;
 var msg = "This is an example of a scrolling message";
 var counter = 0;

 // Is the timer already running?
 if (timerId != null)
    clearTimeout(timerId);

 function pad() {
   var padding  = "";
   // Prepend 50 spaces to the message:
   for (var n=0; n <= (50 + msg.length); n++)
       padding += " ";
   return(padding);
 }

 function scroll() {
  newMsg = pad() + msg + " ";
  document.forms[0].elements[0].value =
           newMsg.substring(counter, newMsg.length);
  if (counter == newMsg.length) {
     counter = 0;
  }
  counter ++;
  timerId = setTimeout("scroll()"1);  
  return true;
 }
//-->
</script>
</head>
<body onLoad="scroll()">
<form>
<center>
<input type="text" size=70>
</center>
</form>
</body>
</html>


           
       
Related examples in the same category
1.Animating Text Styles
2.Moving Text
3.Using the TextRectangle Object Properties
4.Exploring the Bounding TextRange Properties
5.compareEndPoints() Method
6. Two Search and Replace Approaches (with Undo)
7.Using the document.selection Object
8.Encipher and Decipher
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.