This article will teach you how to create an array of all possible entries with simple JavaScript, and then randomly select the images or references you need to add to the webpage. The first step to use this script is to select the Code in the following text and copy it to the rand. js folder.
The Code is 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 to specify the image or reference you need. First, you need to repeat the code () several times as needed until the array includes all the entries you need in the random selection (for example, the starting value of this array is 3, that is to say, if you have 10 entries, you only need to repeat the row seven times ).
If you are using a reference, you just need to replace code (), code1, and code2 with the above text. If you want to use this aunt to display random images, you need to put the HTML code of all the images into the entries. You can create any type of code for your webpage by placing the appropriate HTML and text in the entries, and select randomly.
Finally, use the following code to append 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? 1.1.20 "> </script>