Use JavaScript to display random images or reference _ image effects

Source: Internet
Author: User
The first step in using this script is to select the code in the following text and copy it to the Rand.js folder.
Copy Code code as follows:

var mess = new Array (' code0 ', ' code1 ', ' code2 ');
var max = mess.length;
var num = Math.floor ((math.random () * max));
Document.writeln (Mess[num]);

Now you need to update this code so that it specifies the image or reference you want. First, you have to repeat code () lines several times, as needed, until the array includes all the items you need in a random selection (for example: It starts with a 3, which means that if you have 10 entries, you only need to repeat the line 7 times).
If you are using a reference, you simply need to replace the code () with the above text, and Code1,code2 is OK. If you want to use this lady to display random images, then you have to put the HTML code of all the images into the entry. You can create any type of code for your Web page by placing the appropriate HTML and text in the entry, or randomly selecting it.
Finally, use the following code to attach the script to the main part of your Web page, where you need to display the link or information:
< script type= "Text/javascript" src= "Rand.js" ></script>

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.