PDA

View Full Version : <area onclick help



AnunnakiSpirit
18 Jan 2006, 02:40 PM
Hello, I have a bit of a problem trying to work something out. I have an image with a map on it, what i'm trying to achieve is a div appears exactly where someone clicks the map.


<area name="whatever" onClick="javascript:document.all.whatever.class.display='block'">

<div id="whatever" style="display:none;">
<h2>HI</h2>
</div>


I'm using something similar to the above, but nothing happens on the click.

dingo
18 Jan 2006, 03:05 PM
Try this (not tested it myself), it should at least fix your javascript.


<script type="text/javascript">
function area1Clicked () {
var div1 = document.getElementById("div1");
div1.style.display = "block";
}
</script>

<area name="area1" onClick="area1Clicked()">

<div id="div1" style="display:none;">
<h2>HI</h2>
</div>


But I think you should read this http://www.w3schools.com/tags/tag_area.asp
The area tag must always be nested within a map tag and you must also provide an alt attribute. Also, I'm not sure what happens if you don't specify the coords attribute.