Help - Search - Members - Calendar
Full Version: Dynamic Background Changer
Zymic Webmaster Forums > Web Design & Development > Client Side Scripting > JavaScript
XyberForce
Hey guys, one of my clients is looking for a dynamic way to change the background of a site. ie: click on a link and a new background image loads up. How do I do this? As an example: http://www.purestructure.com/
Andrew
Your example is nothing but a link to an mp4 file, which is broken.

Anyways i'm pretty sure you could do this by changing the style sheets. Set a cookie to make it remember. So a little php involved too. Search for PHP Style Switcher and you could get the basic code for it, then just make a couple different style sheets with only background info in it. And leave your main stylesheet alone.
Banjo
Trippin7464, i looked at the link before and it was an actual site with a stlye switcher where it just changed the background and it was like that on every page ( I don't know what happened to the site though). So the way you said would work.
Kendalls
Try this code:
CODE
<a href="#" onclick="document.body.background='background.jpg';">change background</a>

rockacola
Don't know if this example helps: http://nettuts.com/demos/03_jQueryStyleSwi.../demo/index.php

the javascript code for this is at: http://nettuts.com/demos/03_jQueryStyleSwi...tcher.jquery.js
You may remove other css stylings and just leave the background property.
TehBlizzy
http://stgen.zxq.net/

You can look at that for some info. To make it change the background image, just change it to the "document.body.background='..' stuff

http://stgen.zxq.net/lol.js <-- The javascript to do the stuff
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.