Welcome word for word-to-word character conversion

Source: Internet
Author: User
A colorful welcome word for a webpage is actually a special Javascript text effect, but it is only a combination of typing and colorful. It puts this effect on the corner of the webpage and adds some dynamic elements to the calm webpage.

<Title> welcome word with the same color as character input </title> <body onLoad = "loadText () "> <Script language =" JavaScript "> var someText =" Welcome to Jb51.net "; var aChar; var aSentence; var I = 0; var colors = new Array (" FF0000 ", "FFFF66", "FF3399", "00 FFFF", "FF9900", "00FF00"); var aColor; function loadText () {aColor = colors [Math. floor (Math. random () * colors. length)]; aChar = someText. charAt (I); if (I = 0) aSentence = aChar; else aSentence + = aChar; if (I <50) I ++; if (document. all) {textDiv. innerHTML = "<I>" + aSentence + "</I>"; setTimeout ("loadText ()", 100);} else if (document. layers) {document.textDiv.doc ument. write ("<I>" + aSentence + "</I>"); document.textDiv.doc ument. close (); setTimeout ("loadText ()", 100);} else if (document. getElementById) {document. getElementById ("textDiv "). innerHTML = "<I>" + aSentence + "</I>"; setTimeout ("loadText ()", 100 );}} SCRIPT <p id = "textDiv"> </p> </body>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.