Expanding Text





Put this between your BODY-tags:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var speed = 100;
var cycledelay = 2000;
var maxsize = 28;
var x = 0;
var y = 0;
var themessage, size;
var esize = "</font>";
function initArray() {
this.length = initArray.arguments.length;
for (var i = 0; i < this.length; i++) {
this[i] = initArray.arguments[i];
   }
}
var themessage2 = new initArray(
"JavaScript can do some amazing stuff !",
"Including this expanding text banner !",
"Have you ever seen one of these before ?",
"Neither have your visitors, so put it on your site!!"
);
if(navigator.appName == "Netscape")
document.write('<layer id="wds"></layer><br>');
if (navigator.appVersion.indexOf("MSIE") != -1)
document.write('<span id="wds"></span><br>');
function upwords(){ 
themessage = themessage2[y];
if (x < maxsize) {
x++;
setTimeout("upwords()",speed);
}
else setTimeout("downwords()",cycledelay);
if(navigator.appName == "Netscape") {
size = "<font point-size='"+x+"pt'>"; 
document.wds.document.write(size+"<center>"+themessage+"</center>"+esize);
document.wds.document.close();
}
if (navigator.appVersion.indexOf("MSIE") != -1){
wds.innerHTML = "<center>"+themessage+"</center>";
wds.style.fontSize=x+'px'
   }

function downwords(){
if (x > 1) {
x--;
setTimeout("downwords()",speed);
}
else {
setTimeout("upwords()",cycledelay);
y++;
if (y > themessage2.length - 1) y = 0;
}
if(navigator.appName == "Netscape") {
size = "<font point-size='"+x+"pt'>"; 
document.wds.document.write(size+"<center>"+themessage+"</center>"+esize);
document.wds.document.close();
}
if (navigator.appVersion.indexOf("MSIE") != -1){
wds.innerHTML = "<center>"+themessage+"</center>";
wds.style.fontSize=x+'px'
   }
}
setTimeout("upwords()",speed);
//  End -->
</script>
The var speed = 100; represents the delay rate at which the text expands. A lower value will cause the text to expand much faster.
The var cycledelay = 2000; represents the delay time before the text shrinks back,
and the delay time before another message is displayed.
Decreasing the cycledelay will display the largest font (var maxsize = 28;) of the text in a shorter period of time. It will also shorten the time to shift from one message to another.
The var maxsize = 28;, determines the largest size of the font your text will take. Increasing it will make the font bigger.
The var themessage2 = new initArray(...);. Replace the messages with your own. Add more lines if you want. Just keep in mind that each text line should be wrapped with double quotation marks, and each text line should end with a comma(,) except for the last message.

Free JavaScripts provided
by Winfolinx.com

Back