View Full Version : <area onclick help

18 Jan 2006, 01: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;">

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

18 Jan 2006, 02: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";

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

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

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.