You are currently browsing the tag archive for the 'javascript' tag.

Ever need to display rollover of multiple areas for a single image? Check out this article i found!

Imagemaps

Let’s say we want to have rollovers activated for the shapes in this image. Since this is one image, not three, we need to attach an imagemap. Mouse over the image below, and you can see it in action. As you can see from the HTML, the picture is in file shapes0.png.

square, circle, and triangle

<img src="rollover/shapes0.png" name="shapes" usemap="#shapemap"
    width="283" height="103" alt="square, circle, and triangle"
    border="0" />

Important: It is not possible to replace a part of an image. We have to replace the whole image, so we will need the following image files (named shapes1.png, shapes2.png, and shapes3.png):

square, circle, and triangle; square highlighted square, circle, and triangle; circle highlighted square, circle, and triangle; triangle highlighted

The imagemap will look like a normal imagemap, except that we will add onmouseover and onmouseout attributes to invoke JavaScript.

<map name="shapemap">
    <area shape="rect" coords="20,17,86,88"
        href="#" onmouseover="highlight(1);" onmouseout="highlight(0);" />
    <area shape="circle" coords="134,53,30"
        href="#" onmouseover="highlight(2);" onmouseout="highlight(0);" />
    <area shape="polygon" coords="227,10,180,88,280,88,227,10"
        href="#" onmouseover="highlight(3);" onmouseout="highlight(0);" />
</map>   http://catcode.com/cit041j/js_images2.html

Pages

 

November 2009
M T W T F S S
« Oct    
 1
2345678
9101112131415
16171819202122
23242526272829
30  

RSS Example RSS Real Estate Feed

  • An error has occurred; the feed is probably down. Try again later.