Change Text with Interval

Written by @kerixa 21 August 2012

Use this code if you want to show various messages permanently and in several slides for your users. In this code there is a fixed text. Below this text, another text is displayed as a slide, which changes automatically every 2 seconds.

Code Snippet:

                                                
                                                <!-- this script is provided by www.javascriptfreecode.com coded by: Kerixa Inc. -->
<HTML>
<HEAD>
<TITLE>AMAZING TEXT SLIDESHOW</TITLE>

<SCRIPT LANGUAGE="JavaScript">

     function makeArray() {
     this.length = makeArray.arguments.length;
             for (var i = 0; i < this.length; i++)
             this[i + 1] = makeArray.arguments[i];
     }

     function ccText (val1, val2, val3, val4) {
     this.curText = '';
     this.posit = 1;   
     this.word = val1;  
     this.length = val1.length;
     this.val3 = val3;
     this.val2 = val2;
     this.val4 = val4;
     this.print = ccText2;
     }

     function ccText2() {
             if (this.posit <= this.length) {
             this.curText = this.word[this.posit]
             outStringWord = ccU + this.val3 + this.curText + ccD;
             parent.draw.location = 'javascript:parent.outStringWord';
             this.posit++;
             }
             else {
             doneLoop = true;
             top.location = this.val4;
             }
     }

     function ccTextSlide() {
     if (!doneLoop) reDraw = setTimeout('ccTextSlide()', wordIntro.val2);
     wordIntro.print();
     }

<!--REPLACE THE CONTENT WITH YOUR OWN MESSAGE-->

     var words = new makeArray ('Hello','How Are You Today?','How is The weather','What Do You Like Now','Is This Code Well?');
     var wordIntro = new ccText (words, 2000, '<CENTER><FONT SIZE=5 FACE=VERDANA, ARIAL, Comic Sans MS>', 'http://www.javascriptfreecode.com/');

<!--REPLACE THE ABOVE LINK WITH YOUR LINK-->

<!--CHANGB THE VARIABLES BELOW TO MANIPULATE THE SIZE, COLOR, AND FONT STYLE OF YOUR MESSAGE-->

     var ccU = '<HTML><BODY BGCOLOR="#000000" TEXT= "#000000"><CENTER><H3><FONT FACE=ARIAL SIZE=6 COLOR=#FFFFFF></FONT></h3></CENTER><BR><BR><CENTER><TABLE WIDTH=100% BGCOLOR=#FFFFFF><TR><TD>';
     var ccD = '</TD></TR></table><br><br><br /></HTML>';
     var ccB = ccU + ccD;
     var doneLoop = false;
</SCRIPT>
<FRAMESET onLoad="ccTextSlide()" ROWS="100%, *" FRAMEBORDER=NO BORDER=0>
<FRAME SCROLLING=AUTO SRC="javascript:parent.ccB" NAME="draw" MARGINWIDTH=3 MARGINHEIGHT=3>
</FRAMESET>
</HEAD>

</HTML>
<a target='_blank' href='www.javascriptfreecode.com' style='font-size: 8pt; text-decoration: none'>JavaScript Best Codes</a>                                                
                                            

Example:


About @kerixa

I am Krishna Eydat. I studied Software Engineering at University of Waterloo in Canada. I lead a few tech companies. I am passionate about the way we are connected. I would like to be part of something big or be the big deal!

K

Comments


Here you can leave us commments. Let us know what you think about this code tutorial!

0 / 300

TRENDING POST
1
2
3
4
5
VISITORS
Online Users: 12
Recent Members: Shahmeer, coolcoco7, SmitaPatil25, owoboycute, 092010
advertisement 2