Monday, June 16, 2008

JavaScript: Simple Buttons

well, here is a quick way to replace the images on an html button:

put this code in the 'head' section of the html:
<script>
<!--
function ReplaceImage(image,imgfile){
document.images[image].src = imgfile;
}
-->
</script>

and then use this in the link:
<a href="home.html" onMouseOver="ReplaceImage('home', 'home_down.gif')" onMouseOut="ReplaceImage('home', 'home.gif')"><img name="home" src="home.gif" border="0"></a>

you can also use the 'onClick' attribute to use a JavaScript to load the link; in such case replace the value for 'href' with "#."

No comments: