Rotate a background image

Home/Web Resources/Rotate a background image

 

I am not sure who the author of this script is but it is excellent to use with HTML pages and adds a little functionality.  Elements you need to change are all of the banner

[0]=”Image01URL” lines with real URL’s http://www.mydomain.com/myimage.jpg for example. You will need to give the DIV or table/cell to rotate the background an ID of #header for example

Thats pretty much it. if you want to rotate less images change the line
var random=Math.floor(10*Math.random()); to a lesser number and remove some of the banner[0]=”Image01URL” lines. Well I a sure you get the idea.

Here is the script to copy and paste into the head tags of your HTML document or link to it as a separate .js file. Enjoy.

<!-- Begin Rotate Script-->
<script type=”text/javascript”>
<!– var banner= new Array()
banner[0]=”Image01URL”
banner[1]=”Image02URL”
banner[2]=”Image03URL”
banner[3]=”Image04URL”
banner[4]=”Image05URL”
banner[5]=”Image06URL”
banner[6]=”Image07URL”
banner[7]=”Image08URL”
banner[8]=”Image09URL”
banner[9]=”Image10URL”
var random=Math.floor(10*Math.random());
document.write(”<style>”);
document.write(”#header {”);
document.write(’ background:url(”‘ + banner[random] + ‘”) 
no-repeat top left;’); document.write(” }”); 
document.write(”</style>”); // –></script>
<!-- End Rotate Script-->
2016-10-18T12:04:09+00:00