Hi I am looking for a random background image script. I have 3 background images that cover the whole browser and I want them to rotate when someone hits the refresh button on the browser. Can anyone help me on this thanks.
JimPatrick
JimPatrick
0
Newbie Poster
Recommended Answers
Jump to PostTry this:
<html> <head> <script type="text/javascript"> function randomize(min, max) { if (!min) min = 0; if (!max) max = 1; return Math.floor(Math.random()*(max+1)+min); } function randomBg() { var bgs = new Array(); // I took these images from a site with a similar script already only to get …
Jump to PostYou're going to have something like this:
var srcs = {"images/pic1","images/pic2","images/pic3"}; var index= Math.floor ( Math.random() * 3 ); imagethingy.src = srcs[index];
All 5 Replies
itsjareds
29
Junior Poster
JugglerDrummer
0
Junior Poster
JimPatrick
0
Newbie Poster
JimPatrick
0
Newbie Poster
JimPatrick
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.