Step Three: Attach the Behavior
Currently, Dreamweaver doesn’t support attaching a behavior to an image map. The workaround detailed here is to first attach the behavior to the full images in each layer and then cut and paste the code built by Dreamweaver. Dreamweaver includes a JavaScript Behavior called Show/Hide Layers that does exactly what we need.
Follow these steps to assign the Behavior to the Layers:
<a>,
and proceeds to wrap one around the image targeted to "#".So far, we've assigned one Behavior to make the onLayer visible when the pointer is over the image. Now we have to assign another Behavior to hide the onLayer when the pointer moves away from the image.
So what we now have is two Behaviors
assigned to one image. At this point the Dreamweaver code for the <body>
of our Web page reads like this:
<body bgcolor="#FFFFFF">
<div id="offLayer" style="position:absolute; width:200px; height:115px;
z-index:1; visibility:visible">
<a href="#" onmouseover = "MM_showHideLayers('document.layers[\'onLayer\']','document.all[\'onLayer\']','show')"
onmouseout = "MM_showHideLayers('document.layers[\'onLayer\']','document.all[\'onLayer\']','hide')">
<img src="images/imagemap.jpg" width="607" height="191" border="0"></a>
</div>
<div id="onLayer" style="position:absolute; width:200px; height:115px;
z-index:2; overflow:visible; visibility: hidden">
<img src="images/imagemap2.jpg" width="607" height="191">
</div>
</body>
The MM_showHideLayers()
JavaScript function called by both onMouseOver and onMouseOut is automatically
written to the <head>
section. Part of this technique involves
adding and modifying that code a bit which we'll cover in Step Five.
|
|
Step Three: Attach the Behavior |