Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[javascript] Flipping Messages
#1
Credits and Source: http://jsmadeeasy.com/

Name: Flipping Messages
Description: When given a text box, JavaScript can flash messages in it. Similar to a scroll, but no scrolling is involved - otherwise it would be a scroll, not a game Smile
Snippet:

Insert into <HEAD>

Code:
<SCRIPT LANGUAGE="JavaScript">



<!-- Begin
var CurrentMsg = 'Hello?  Welcome to The JavaScript Source!!';
function update(msg) {
var pad_str="";                          
n = msg.length;
if(n<72) {
pad = (73-n)/2;
for(var i=0; i<pad; i++) {
pad_str+=" ";                        
   }                        
}                          
CurrentMsg = pad_str + msg;                          
document.getElementById("field").value = CurrentMsg;
clearTimeout(timer);                          
timer = setTimeout("idleMsg()",2500);        
}
function MakeArray(n) {                          
this.length=n;                          
for(var i = 1; i<= n; i++) {                                  
this[i] = "";                
}                          
return(this);        
}              
var index = 1;          
var notice_num = 9;                  
var notices = new MakeArray(notice_num);        
notices[1] = "Welcome to The JavaScript Source!";
notices[2] = "Hey, thanks for coming!  I am glad you visited!";
notices[3] = "Each message can be adjusted either in speed, or content.";        
notices[4] = "The length of the message box can also be personalized to fit your needs.";
notices[5] = "More scripts to this effect can be found throughout this site.";
notices[6] = "Don't forget to get your own home page to show off all your scripts!";
notices[7] = "I hope that these scripts help you to improve your web site!!";      
notices[8] = "Be sure to sign my guestbook and complete my survey before you leave!";                    
var timer = setTimeout('idleMsg()',1500);                  
function nochange() {
document.getElementById("field").value = CurrentMsg;
}                  
function idleMsg() {                          
update(notices[index++]);                          
if(index>notice_num) {
index=1;
   }  
}
// End -->                  
</SCRIPT>

Insert into <BODY>

Code:
<CENTER>
<FORM name="messages" onSubmit="return false">
<input type="text" id="field" name="field" size=73 value=" Hello?  Welcome to TJS!!" onFocus="self.status='This is a JavaScript information data field'; return true" onChange="nochange()">
</FORM>
</CENTER>


Thats It. Thankyou for reading. Glare
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Free Worker HTML, CSS, Javascript ImFocuzz 2 1,104 04-05-2014, 10:01 PM
Last Post: VHPanda
  [MyBBError Message] PLEASE HELP ME!! Enable Javascript Registration Error iRun 4 1,647 01-26-2012, 03:13 PM
Last Post: iRun
  Close Tab With Javascript. Qua 3 1,239 07-02-2011, 07:25 AM
Last Post: djakariuz
  Keyboard shortcuts with JavaScript faviouz 12 2,636 05-07-2011, 01:21 AM
Last Post: Danny
  Javascript Help. Form Submission. JohnRonder 0 789 02-01-2011, 11:12 AM
Last Post: JohnRonder

Forum Jump:


Users browsing this thread: 1 Guest(s)