Switch Background Image onClick
-
Hi Guys,
I am making a theme that will hopefully let you change the pages background image by clicking a link on an image map. The code I am using is this:<img src="images/Cactus_Home_Button.jpg" border="0" usemap="#Map1" /> <map name="Map1" id="Map1"> <area shape="poly" coords="20,40,335,7,339,30,22,64" href="<?php echo get_settings('home'); ?>" alt="Homepage"/> <area shape="poly" coords="22,67,111,57,111,77,24,87" href="#" onClick="document.body.background='<?php bloginfo('template_directory'); ?>/images/surfbackdrop1.jpg'" alt="Change to Surf Background Image" /> <area shape="poly" coords="119,56,120,77,226,67,225,45" href="#" onClick="document.body.background='<?php bloginfo('template_directory'); ?>/images/skatebackdrop1.jpg'" alt="Change to Skate Background Image" /> <area shape="poly" coords="233,44,233,65,336,55,341,33" href="#" onClick="document.body.background='<?php bloginfo('template_directory'); ?>/images/snowbackdrop1.jpg'" alt="Change to Snow Background Image" /> </map>The page is here: http://www.popmag.com.au/cactusblack/
The problem is it doesn’t work. I’m not sure why. If I put it into a normal HTML page it works fine, so I suspect it is something to do with WordPress and its PHP page constructing. Anyway, it’s over my head so I thought I would ask here.
There might be a better way to achieve this (like switching the entire style sheet) although this way seems the most efficient, so let me know what you think.
Thanks,
Drew
The topic ‘Switch Background Image onClick’ is closed to new replies.