This is all much more complicated than it needs to be. You don't need any involved, self contained script. All of your code can be written into the events within the division tag (simple preloading code in the head for the rollover image is a nice touch):
HTML Code:
<div style="background:url(main_button_up.gif);" onmouseover="this.style.background='url(main_button_down.gif)'" onmouseout="this.style.background='url(main_button_up.gif)'">
<a href="about/about.html" >About me</a>
</div>
Then in the head, preloading code for the rollover:
Code:
<script type="text/javascript">
img1=new Image();
img1.src="main_button_down.gif"
</script>
If you are wanting to do this for a bunch of links, you can use a stylesheet in the head or externally. In the head, the stylesheet could look like this:
Code:
<style type="text/css">
.up {
background:url('main_button_up.gif');
}
.down {
background:url('main_button_down.gif');
}
</style>
Keep the same preloading script as in the first example in the head but now, your html markup for the division tag changes to:
HTML Code:
<div class="up" onmouseover="this.className='down'" onmouseout="this.className='up'">
<a href="about/about.html" >About me</a>
</div>
Bookmarks