Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7787291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:37:02+00:00 2026-06-01T20:37:02+00:00

I try to add a to an HTML-Document and link it to an image

  • 0

I try to add a to an HTML-Document and link it to an image using the following code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="de">
<head>
    <title>Website</title>
    <script type="text/javascript">
    function addArea(map, xstart, ystart, xende, yende, idCol, col) {
        area = document.createElement("area");

        area.shape  = "rect";
        area.coords = "" + xstart + ", " + ystart + ", " + xende + ", " + yende + "";
        area.href   = "#" + idCol;
        area.title  = col;
        area.alt    = col;
/*
        area.shape  = "\"rect\"";
        area.coords = "xstart + \", \" + ystart + \", \" + xende + \", \" + yende";
        area.href   = "\"#\" + idCol";
        area.title  = "col";
        area.alt    = "col";

*/      area.setAttribute(
            "onclick",
            "alert(\"Color: \" + col); return false;"
        );

        // append the area to the map
        map.appendChild(area);
    }

    function showMap() {
        idCol = "text";

        // generate the map
        mapCol      = document.createElement("map");
        mapCol.name = "map_" + idCol;
        mapCol.id   = "map_" + idCol;
        addArea(mapCol, 1, 1, 25, 13, idCol, "00FF00");
        addArea(mapCol, 25, 1, 49, 13, idCol, "00FF33");


        imgCol              = document.createElement("img");
        imgCol.src          = "https://www.google.de/images/srpr/logo3w.png";
        imgCol.width        = 275;
        imgCol.height       = 95;
        imgCol.style.border = "1px solid #000";
        imgCol.usemap       = "#name_und_raute_sind_notwendig_bunt_" + idCol;
        imgCol.alt          = "Farbe auswählen";

        imgColArea      = document.createElement("p");
        imgColArea.appendChild(imgCol);

        testcol = "ffffff";
        testlink    = document.createElement("a");
        testlink.appendChild(document.createTextNode("testlink"));
        testlink.setAttribute(
            "onclick",
            "alert(\"Color: \" + testcol); return false;"
        );

        document.getElementById("area").appendChild(imgColArea);
        document.getElementById("area").appendChild(testlink);

        alert("map added with " + mapCol.areas.length + " entries.");

    }


    </script>
</head>
<body onLoad="showMap()">
<div>
before
<div id="area"></div>
after
</div>
</body>

The image should contain linked areas, that alert a text when clicking on them. Unformtunatly the areas do not show up. Does anyone find my mistake?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:37:04+00:00Added an answer on June 1, 2026 at 8:37 pm

    First of all, your map identifiers mismatch. Also the property name is useMap, not usemap. Use

    imgCol.setAttribute('usemap',"#" + mapCol.name);
    

    or

    imgCol.useMap = "#" + mapCol.name;
    

    instead. You also have to add your map to the document:

    /* ... */
    imgColArea.appendChild(imgCol);
    imgColArea.appendChild(mapCol);
    /* ... */
    

    JSFiddle demonstration

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using js to add form elements into the html document. For instance, I'm
I have the following code that I'm trying to retrieve the HTML document. Not
I try to add an addons system to my Windows.Net application using Reflection; but
I try to add a class to a td-element using javascript with the internet
I try to add a class to a link with jquery <a rel=/Career/ href=/Career/></a>
I'm writing a program to add some code to html files I was going
I have the following issue using java 1.4 I try to display a very
I am trying to follow this example: http://msdn.microsoft.com/en-us/library/aa179614%28SQL.80%29.aspx# It says to add the following
I try add javascript to my velocity template. <html> <head> <title>:: $currency.CurrencyName Detail Info
My IDE crashes any time I try add a new component to the toolbar.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.