Random Number for special effects of JavaScript webpage Creation

Source: Internet
Author: User

The online world is amazing. If special effects are used properly on beautiful pages, they will certainly increase. The following is my summary of special effects:
Beating text
Want to see the dancing text? Come on!
Code: First add <script language = "JavaScript"> between <〈! --
Function font11 ()
// Define the function font11 ()
{
Document. all. a1.style. fontSize = 16 +
Math. floor (Math. random () * 24); // call Math. the random () function generates a random number and uses Math. the floor () function is generated less than or equal to Math. the next number of random () * 24 to change the text size.
C1 = Math. floor (Math. random () * 256 );
C2 = Math. floor (Math. random () * 256 );
C3 = Math. floor (Math. random () * 256 );
Document. all. a1.style. color = "rgb (" + c1 + "," + c2 + "," + c3 + ")"; // same as above, change the text color (color using RGB)
Timer = setTimeout ('font11 () ', 200); // call the font11 () function every 200 milliseconds
}
---> </Script> 〉
Add onLoad = "font11 ();"
Add <span id = "a1"> Fei </span> 〉
Features: The text color and size can be changed randomly.
Extension: multiple groups of code can be added to the webpage. font11 represents different texts, including font12 and font13 in the future. The text can be represented as different texts.
Fade in and out
As time passes, the image will change from fuzzy to clear.
Code: First add <script language = "JavaScript"> between <〈! --
Mark = 0;
Function tupian () // CREATE function tupian ()
{
If (photo. filters. alpha. opacity <10)
// When the image transparency is less than 10
Mark = 1;
If (photo. filters. alpha. opacity> 98)
// When the image transparency is greater than 98
Mark =-1;
Step = 2 * mark;
Photo. filters. alpha. opacity + = step;
// Transparent value counter Accumulation
SetTimeout ('tupian () ', 20 );
// Execute the program every 20 milliseconds
}
---> </Script> 〉
Add id = "photo" and style = "filter: alpha (opacity = 0;)" to the image attributes ;)"
Finally, add the script after the image code 〉〈! --
Tupian ();
---> </Script> 〉
Feature: The image fades in and out cyclically.
The code in this article is very simple and I have explained all the points to be explained.

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.