This article describes the random display of image effects when JS implements page loading. Share it for your reference, as follows:
<html> <head> <title>JS Random picture effects</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <style type="text/css"> <!-- img { border: #999999; border-style: dotted; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px} --> </style> </head> <SCRIPT LANGUAGE="JavaScript"> var rand1 = 0; var useRand = 0; images = new Array; images[1] = new Image(); images[1].src = "img/"; images[2] = new Image(); images[2].src = "img/"; images[3] = new Image(); images[3].src = "img/"; images[4] = new Image(); images[4].src = "img/"; function swapPic() { var imgnum = - 1; do { var randnum = (); rand1 = ((imgnum - 1) * randnum) + 1; } while (rand1 == useRand); useRand = rand1; = images[useRand].src; } </script> <body bgcolor="#FFFFFF" text="#000000" OnLoad="swapPic()"> <img name="randimg" src="img/"> </body> </html>
The code is tested and runs normally. I will no longer have the running renderings here. Interested friends can choose a few pictures of beautiful women to test them to see the effect.
For more information about JavaScript, readers who are interested in reading this site's special topic:JavaScript traversal algorithm and skills summary》、《Summary of JavaScript switching effects and techniques》、《Summary of JavaScript search algorithm skills》、《Summary of JavaScript animation special effects and techniques》、《Summary of JavaScript Errors and Debugging Skills》、《Summary of JavaScript data structure and algorithm techniques"and"Summary of JavaScript mathematical operations usage》
I hope this article will be helpful to everyone's JavaScript programming.