Hello,
How do I make a background changer?
Where a user can select a background and it changes without refreshing.
I want them to click say a 50px*50px image and the background change to that image (the image will be tiled).
Thanks
Tom
Hello,
How do I make a background changer?
Where a user can select a background and it changes without refreshing.
I want them to click say a 50px*50px image and the background change to that image (the image will be tiled).
Thanks
Tom
Here you goThis is the script that I wrote for my site. Put this in the head:
Then you can call it pretty easily. For example, if you want to change the background colour when you click a specific image:Code:<script type="text/javascript"> function setBackgroundImage(url) { document.body.style.backgroundImage = 'url(' + url + ')'; } </script>
I have different version on my site that changes the background, and then loads a PHP page which saves your choice into a cookie.Code:<img src="whatever.jpg" alt="This will change the bg to bg.gif" onClick="setBackgroundImage('bg.gif')" />
i used to be NintendoNews. visit my blog or add me on twitter.
need help with vista? i am a microsoft certified technology specialist in configuring windows vista and connected home integrator.. pm me for help!
"I am the way, the truth, and the life. No one comes to the Father except through me"
John 14:6 (NIV)
Just put the Javascript bit into the head of your page. Then, for example, if the image was called "animage.gif" and you wanted to change the background to itself when you clicked it, you would use this code for the image:
Code:<img src="animage.gif" alt="An image" onclick="setBackgroundImage('animage.gif')" />
i used to be NintendoNews. visit my blog or add me on twitter.
need help with vista? i am a microsoft certified technology specialist in configuring windows vista and connected home integrator.. pm me for help!
"I am the way, the truth, and the life. No one comes to the Father except through me"
John 14:6 (NIV)
. I wanted this a while ago. Thanks tim +rep
edit: need to spread![]()
Want to hide these adverts? Register an account for free!