| Use JavaScript to randomly display pictures Sometimes you can see some of the changes displayed on some websites, except that you can use Flash to make Of course, you can also use this section of the tutorial introduced the method to achieve OH. All right, let's start with our creations. We can add the following code in the front of the page to create a random number: <script> <!-- //randomizer Rnd.today=new Date ( ); Rnd.seed=rnd.today.gettime (); Function rnd () { Rnd.seed = (rnd.seed*9301+49297)% 233280; Return rnd.seed/(233280.0); }; Function rand (number) { return Math.ceil (Rnd () *number); }; //End Randomizer </script> To create a random number from 1 to 10, you can rand (7). To display a random display from num1.gif to Num7.gif, you can write the following code to your Web page: <script language= "javascript" ><!-- document.write (' width= ' height= ' > '); !----> file://--></ script> All OK, you can enjoy your masterpiece. Until now you may have a bit more experience with javascript: The JavaScript feature is so powerful. I think this is largely due to the many functional functions that JavaScript has. |