Changing background images
- Started
- Last post
- 5 Responses
- honest
Hi folks, annoying print designer here with a silly web question on behalf of my wife (Japanese) who is teaching herself web development:
She wants to be able to have different background images loading on each visitation on a homepage.
How best to apply simple code for this? Is this that CSS magic that I keep hearing of or the powerful flash-killer that is Javascript?
- omgitsacamera0
Javascript
- Stugoo0
put the background image in using inline css.
then use a javascript function to pic an image at random.
- PSYKHO0
This works:
<SCRIPT LANGUAGE="Javascript"><!-- function bkgrnd() {} ; bg = new bkgrnd () ; n = 0 bg[n++] = "images/Image1.gif" bg[n++] = "images/Image2.gif" bg[n++] = "images/Image3.gif" bg[n++] = "images/Image4.gif" bg[n++] = "images/Image5.gif" //Just keep adding rnd = Math.floor(Math.random() * n) ; tmp = '<BODY BACKGROUND="' +bg[rnd]+ '"' +' BGCOLOR="#FFFFFF">' //--></SCRIPT></HEAD> <SCRIPT LANGUAGE="Javascript"><!-- document.write( tmp ) //--></SCRIPT>
- Forgot to remove the end header tag: </HEAD> works non the less.PSYKHO
- VectorMasked0
what they said ^^^
Because is she was german, the method would be different; and if she was Portuguese it could simply not be done.
;o)