stuu
08-31-2006, 05:17 AM
Hi, the following is my code. I have a MAP(50x50px) , and 4 AREAs (25x25px).
I want a mouseover event on the AREA where DIV 'd'(a 25x25px gif in different color) is shown up on the AREA. But i have problem with the positioning. I try to use the coords property, but it seens weird. It there a better way to do it. Also when i resize the browser, the image is totally out of position. Thank you for helping.
code
---------------------
function b(obj)
{
if(obj)
{
str=obj.coords.split(",")
document.getElementById('b').style.left = parseInt(str[0])+503;
document.getElementById('b').style.top = parseInt(str[1])+167;
document.getElementById('b').style.display="block";
}
else
document.getElementById('b').style.display="none";
}
<body>
<div id="b" style="position:absolute;display:none;z-index:99;">
<img src="select.gif"></div>
<p align="center">
<map name="map" id="map">
<area id="pix1" shape="rect" coords="0,0,25,25" onmouseover="b(this)" onmouseout="b()" href="1"/>
<area shape="rect" coords="25,0,50,25" onmouseover="b(this)" onmouseout="b()"href="2"/>
<area shape="rect" coords="0,25,25,50" onmouseover="b(this)" onmouseout="b()"href="3"/>
<area shape="rect" coords="25,25,50,50" onmouseover="b(this)" onmouseout="b()"href="4"/>
</map><img border="0" src="map.gif" width="50" height="50" ismap usemap="#map"></p>
</body>
I want a mouseover event on the AREA where DIV 'd'(a 25x25px gif in different color) is shown up on the AREA. But i have problem with the positioning. I try to use the coords property, but it seens weird. It there a better way to do it. Also when i resize the browser, the image is totally out of position. Thank you for helping.
code
---------------------
function b(obj)
{
if(obj)
{
str=obj.coords.split(",")
document.getElementById('b').style.left = parseInt(str[0])+503;
document.getElementById('b').style.top = parseInt(str[1])+167;
document.getElementById('b').style.display="block";
}
else
document.getElementById('b').style.display="none";
}
<body>
<div id="b" style="position:absolute;display:none;z-index:99;">
<img src="select.gif"></div>
<p align="center">
<map name="map" id="map">
<area id="pix1" shape="rect" coords="0,0,25,25" onmouseover="b(this)" onmouseout="b()" href="1"/>
<area shape="rect" coords="25,0,50,25" onmouseover="b(this)" onmouseout="b()"href="2"/>
<area shape="rect" coords="0,25,25,50" onmouseover="b(this)" onmouseout="b()"href="3"/>
<area shape="rect" coords="25,25,50,50" onmouseover="b(this)" onmouseout="b()"href="4"/>
</map><img border="0" src="map.gif" width="50" height="50" ismap usemap="#map"></p>
</body>