Home >> Tutorials >> Javascript tutorials

Previous page and Next page
Image button Alert button Prompt button
Scrolling button Rotating button Confirmation button
This is an example for displaying scrolling messages in a button using javascript.Eg:

Source Code:
<body > 
<form name="testform"> 
<input type="button" name="messagebutton"  size=130 value=""> 
<script language="Javascript"> 
var MessageText= "This is a test message for scrolling text on a button" 
var MsgPosition=0; 
var MsgSeperator = "..."; 
function StartScrolling() { 
document.testform.messagebutton.value=MessageText.substring(MsgPosition,MsgPosition+60)+MsgSeperator + MessageText.substring(0, MsgPosition); 
if(MsgPosition>MessageText.length) MsgPosition=0; 
// repeat at entered speed 
window.setTimeout("StartScrolling()",100); }StartScrolling();// --></script> 

if you want to load a page when clicked ,add the following function.
function ButtonURL(){

then change the <input type="button" name="messagebutton"  size=130 value="" onclick="ButtonURL()">
Rotating button(Button with Rotating Text
Following is the example for rotating button. It display a couple of interesting websites on a round-robin manner. On clicking it will take you to the corresponding website.<head> 
<SCRIPT LANGUAGE="JavaScript"><!-- beginvar MsgPosition =0; 
var ArrayItems=Array("CNN","infoseek","IBM","Yahoo","Excite","WEBGIMMICKS"); 
var URLArray=Array("http://www.cnn.com", "http://www.infoseek.com", 
 "http://www.webgimmicks.com")function StartRotating() { 
 (MsgPosition <ArrayItems.length-1) ? MsgPosition++  : MsgPosition=0; 
 document.forms[0].elements[0].value=ArrayItems[MsgPosition];   TimerHandle=window.setTimeout('StartRotating()',1000);} 
function LaunchURL()  { 
   return (false); 

// end --></SCRIPT></head> 
<BODY onLoad="window.StartRotating()"> 
<INPUT TYPE="button" VALUE="  Rotating button "  NAME="RotateButton" 
If you click this button, it will take you to the corresponding web site ... 


Page contents: itechies.net – Learn how to display a scrolling text message on a form button, or button with Rotating Text using javascript.