[Javascript] FW: whats wrong

Tim Makins spindrift at oceanfree.net
Sun Jul 25 01:19:29 CDT 2004


----- Original Message ----- 
From: "Iztok Polanic" <iztok.polanic at amis.net>
To: "'[JavaScript List]'" <javascript at LaTech.edu>
Sent: Saturday, July 24, 2004 6:59 PM
Subject: RE: [Javascript] FW: whats wrong


> Hi!
> 
> What are the standard mouverover techniques? :)


Something like this, from 'Using JavaScript', by Paul McFedries:


<html>
<head>
<title>Listing 24.9. Preloading Mouseover Images</title>

<script language="JavaScript" type="text/javascript">
<!--

var home_image_over = new Image(200, 35)
home_image_over.src = "home_over.gif"
var home_image_out = new Image(200, 35)
home_image_out.src = "home_out.gif"

var sitemap_image_over = new Image(200, 35)
sitemap_image_over.src = "sitemap_over.gif"
var sitemap_image_out = new Image(200, 35)
sitemap_image_out.src = "sitemap_out.gif"

var support_image_over = new Image(200, 35)
support_image_over.src = "support_over.gif"
var support_image_out = new Image(200, 35)
support_image_out.src = "support_out.gif"

var contact_image_over = new Image(200, 35)
contact_image_over.src = "contact_over.gif"
var contact_image_out = new Image(200, 35)
contact_image_out.src = "contact_out.gif"

function mouseover_handler(image_name) {

    // Get the variable name for the preloaded mouseover image
    mouseover_image = eval(image_name + "_over")
    
    // Switch to the mouseover image
    document.images[image_name].src = mouseover_image.src
}

function mouseout_handler(image_name) {

    // Get the variable name for the preloaded mouseout image
    mouseout_image = eval(image_name + "_out")
    
    // Switch to the mouseout image
    document.images[image_name].src = mouseout_image.src
}

//-->
</script>

</head>

<body>

<a href="javascript:void(0)"
   onMouseOver="mouseover_handler('home_image')"
   onMouseOut="mouseout_handler('home_image')">
<img src="home_out.gif" name="home_image" border="0"></a>
<br>
<a href="javascript:void(0)"
   onMouseOver="mouseover_handler('sitemap_image')"
   onMouseOut="mouseout_handler('sitemap_image')">
<img src="sitemap_out.gif" name="sitemap_image" border="0"></a>
<br>
<a href="javascript:void(0)"
   onMouseOver="mouseover_handler('support_image')"
   onMouseOut="mouseout_handler('support_image')">
<img src="support_out.gif" name="support_image" border="0"></a>
<br>
<a href="javascript:void(0)"
   onMouseOver="mouseover_handler('contact_image')"
   onMouseOut="mouseout_handler('contact_image')">
<img src="contact_out.gif" name="contact_image" border="0"></a>

</body>
</html>



More information about the Javascript mailing list