Class Schedule
This work
is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
home & schedule | syllabus | contact | grades
A second example of the same thing, with different images
UNIX/LINUX ⇒ | command | argument | value |
HTML ⇒ | tag | attribute | value |
CSS ⇒ | selector | declaration property | declaration value |
JavaScript ⇒ | script | type | text/javascript |
followed by the script components
Look at this MouseOver Image example, noting the code and the script components, the inline CSS for body background, and the linking of the alternating image to an absolute location.
<html>
<head>
<script type="text/javascript">
<!--
// preload two images - they must be the same size!
// Note here the image is 228 pixels wide and 184 pixels high.
var normalButton = new Image(228,184);
var reverseButton = new Image(228,184);
normalButton.src = "images/unc_duke.jpg";
reverseButton.src = "images/UNC_athleticsLOGO.jpg";
// -->
</script>
</head>
<body bgcolor="gray">
<h2>MouseOver on an Image</h2>
<p>
This page illustrates using the <em>mouseOver</em> on an image.
As you drag the mouse over the image, notice how the image changes.
</p>
<p>
<a href="https://www.unc.edu/"
onMouseOver="document.ThisImg.src = reverseButton.src; return true"
onMouseOut="document.ThisImg.src = normalButton.src; return true">
<img name="ThisImg" src="images/unc_duke.jpg" />
</a>
The second replaces the initial one.
</p>
</body>
</html>
Try to modify this code for your own use. You may use any pair of images, but you must store them in the same subdirectory where you store your page code [so the script can find them in order to display them]. Here are two you can download for use.
These two images are the same size, but you may need to take a look at other images in an image editing software program to determine the size of the image. You will need to use these in order to change the size attributes for the images in the script.
This page illustrates using the mouseOver on an image. As you drag the mouse over the image, notice how the image changes.
The second replaces the initial one.
There are many, many scripting books on the market right now, more than 100 on JavaScript alone. The example here was modified from an old book, JavaScript Bible by Danny Goodman.
There are many places on the web where you can find free JavaScripts to use, but one of them most useful is Dynamic Drive.
02 March lab | practice with client side scripts | one more time