Java Reference
In-Depth Information
{
window.location.replace(“notieonly.htm”);
}
}
The
notieonly.htm
page is identical, except that in your
if
statement you check if the browser is
MSIE
and redirect to
ieonly.htm
if it is.
function checkBrowser()
{
if (getBrowserName() == “MSIE”)
{
window.location.replace(“ieonly.htm”);
}
}
Exercise 3 Question
Insert an image in the page with the
<img/>
element. When the mouse pointer rolls over the image, it
should switch to a different image. When the mouse pointer rolls out (leaves the image), it should swap
back again. (Hint: These events are
mouseover
and
mouseout
.)
Exercise 3 Solution
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>Chapter 6: Question 3</title>
<script type=”text/javascript”>
function mouseOver(that)
{
that.src = “Img2.jpg”;
}
function mouseOut(that)
{
that.src = “Img1.jpg”;
}
</script>
</head>
<body>
<img src=”Img1.jpg” name=”myImage” onmouseover=”mouseOver(this)”
onmouseout=”mouseOut(this)” />
</body>
</html>
Save this as
ch06_q3.htm
.