Results 1 to 2 of 2

Thread: <area onclick help

  1. #1
    Join Date
    Jan 2006
    Posts
    1

    <area onclick help

    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.

    Code:
    <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.

  2. #2
    Join Date
    Mar 2005
    Posts
    127
    Try this (not tested it myself), it should at least fix your javascript.
    Code:
    <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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •