Simple javascript problems

Permalink
I'm sure there's a much more elegant way of doing this but I'm on a tight deadline and probably just need someone else to take a look at this point. (So I appreciate help in advance).

I made a side navigation that changes the background image in another div on the page when you hover.

Javascript code (right now I just have it in the header of my default.php)
<script language="javascript" type="text/javascript">
   function changeBg(newBg)
      {
    var imgdiv = document.getElementById("mainimg");
    imgdiv.style.backgroundImage = "url(" + newBg + ")";
   }
   </script>


When I made the initial html version this is the side navigation code I used:
<a href="index.html" onmouseover="changeBg('images/photo1.png')" onmouseout="changeBg('images/photo1.png')"><img name="home" src="<?=$this->getThemePath()?>/images/nav-home.png" width="217" height="276" /></a><br />
  <a href="index.html" onmouseover="changeBg('images/photo2.png')" onmouseout="changeBg('images/photo1.png')"><img name="home" src="<?=$this->getThemePath()?>/images/nav-getinvolved.png" width="217" height="66" /></a><br />
  <a href="index.html" onmouseover="changeBg('images/photo3.png')" onmouseout="changeBg('images/photo1.png')"><img name="home" src="<?=$this->getThemePath()?>/images/nav-docs.png" width="217" height="67" /></a><br />
  <a onmouseover="changeBg('images/photo4.png')" onmouseout="changeBg('images/photo1.png')" href="events.html"><img src="<?=$this->getThemePath()?>/images/nav-beheard.png" width="217" height="78" /></a>


Because I can't add get theme path directly to the onmouseover script how do I get C5 to find those images?

If it's helpful here's an html test version:http://www.alta-dev.com/SLOcoastaltrail/...

AltaPlanning
 
12345j replied on at Permalink Best Answer Reply
12345j
if its just for your site you can input the full path- likehttp://www.mysite.com/images/images1... etc.
AltaPlanning replied on at Permalink Reply
AltaPlanning
Yeah that's what I ended up doing so it all works now.

But if anyone has any more streamlined solutions let me know.

Thanks!

This website stores cookies on your computer. These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media. To find out more about the cookies we use, see our Privacy Policy.