This site designed with Coffee Cup HTML Editor++ ver. 6.2 |
HTML Tutorial |
JavaScript Examples |
Rollovers |
MouseDown |
JS Clock |
CountDown |
Status Window |
Status Window 2 |
Random Image |
JS Cookies |
Background Changer |
Scrolling Banner |
Members Area |
*NOTE: Java Script IS case sensitive. Mix up the upper & lower cases in the image names and it will not work.
Start with this:
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">// Tells Browser that this is a Script
<!--
if (document.images) { //Preloads images into browser and defines them by name & size
img01on=new Image(60,40);
img01on.src="Images/Back3.gif";
img01off=new Image(60,40);
img01off.src="Images/Back4.gif";
img02on=new Image(60,40);
img02on.src="Images/Home3.gif";
img02off=new Image(60,40);
img02off.src="Images/Home4.gif";
img03on=new Image(60,40);
img03on.src="Images/Next3.gif";
img03off=new Image(60,40);
img03off.src="Images/Next4.gif";
}
function imgOn(imgName) { //Defines the Rollover functions
if (document.images) {
document[imgName].src=eval (imgName + "on.src");
}
}
function imgOff(imgName) {
if (document.images) {
document[imgName].src=eval (imgName +"off.src");
}
}
// -->
</SCRIPT> //Ends preload & function definition
<TITLE>Rollovers in JavaScript</TITLE></HEAD>
<CENTER><TABLE WIDTH=180 BORDER=0><TR>
<TD><A HREF="Otherpage.html" onMouseOver="imgOff('img01','Back4')"
onMouseOut="imgOn('img01','Back3')">
<IMG ALIGN=LEFT NAME="img01" SRC="Images/Back3.gif" Width=60 HEIGHT=40 BORDER=0></A></TD>
<TD><A HREF="Anotherpage.html" onMouseOver="imgOff('img02','Home4')"
onMouseOut="imgOn('img02','Home3')">
<IMG ALIGN=LEFT NAME="img02" SRC="Images/Home3.gif" Width=60 HEIGHT=40 BORDER=0></A></TD>
<TD><A HREF="Athirdpage.html" onMouseOver="imgOff('img03','Next4')"
onMouseOut="imgOn('img03','Next3')">
<IMG ALIGN=LEFT NAME="img03" SRC="Images/Next3.gif" Width=60 HEIGHT=40 BORDER=0></A></TD>
</TR></TABLE></CENTER>
</BODY>
</HTML>
*Here's a sample of Rollovers in JavaScript that you can take with you. Just copy & paste it from here into your text editor and save it for future reference. Remember, you can change the "Image Names" to whatever you like, and you can use your own imagery, just be sure to get the file addresses and image names right in your code.