Expanding the skill set: JavaScript and CSS Background Changer

February 28th, 2007

Once again I find myself confronted with having to use Javascript for a project. This time a dynamic background changer was needed (aka skin toggle). Using my feeble JavaScript Skills and a bit of copy and pasting I manage to put together a working template.

Here is an example. You can change the background of this site by clicking on the following thumnails:

How it works:
Firstly the background images are created/selected and placed in a folder together. Next name them the same with a just changing a number/letter/word at the end that. I recommend numbering them sequentially.

In an image editor crop small area of the image you will use as a button for it. You can of course use text buttons instead. In this case I have chosen to make the area around the buttons to change background to match the background image. If you want this effect then crop the large background images into smaller ones that match the size of the area you want to skin. Name the small background images the same as their larger counterparts adding a letter/number to the end. In the example I have used letter ‘a’.

Continue reading »

    About

    Although originally designed to document my work and new web development tricks I learnt it has expanded to cover tech and news that I find interesting so in addition to tutorials and interviews expect to see product reviews and tech news too. If you enjoy please comment. David

    Blogroll
    • Adele Kirby - Freelance Writer and most chipper/perky person alive
    • Alex Pullin - Freelance Tech Writer and former PR queen
    • Display: Block - Blog of fellow developer Savell Martin
    • Molly E. Holzschlag - Web standards advocate and Genious
    • Nate Laxon - Funny guy and music guru
    • Paul Boag - Helping website owners and promoting webstandards. The King of Web Design Podcasts
    • Poached Online - news/current affairs/political comment: no eggs
    • Tale of 2 Blogs - Blog about my other blogs
    Admin
  • From Display:Block
    • SpringWidgets
      RSS Reader
      This widget is the staple of our platform. Read all your feeds right here with this one widget - Supported feeds are OPML, RSS, RDF, ATOM. Watch your favorite Podcast in the embedded Video Player on the Desktop or publish your own video playlist to your site for others to view!
      Visit the Widget Gallery