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 400821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:58:39+00:00 2026-05-12T16:58:39+00:00

Is there a way to create an imagemap on an image when the image

  • 0

Is there a way to create an imagemap on an image when the image is created in Javascript?

So image is created this way:

var img = new Image(); 

then set all properties.

But how do I now create an imagemap on this image?

Regards,
Tony

UPDATE

Here’s my code to create image:

  function createimg()
  {
       var img = new Image();
       img.src='Image/URL';
       img.alt='Next image';  
       img.id = 'span1';
       img.style.zIndex = 10;
       img.style.position = 'absolute';  
       img.style.display='none'; 
       img.style.top = '130px';
       img.style.padding='10px'; 
       img.style.left='440px'; 
       img.usemap='#trialmap';   
       img.className ='dynamicSpan';
       document.body.appendChild(img);
       return img;
  }

This sits in inside tags. Now imagemap:

<map name="trialmap">
    <area shape ="rect" coords ="0,0,500,500"
     href ="http://www.google.com" target ="_blank" alt="Sun" />

    <area shape ="circle" coords ="100,100,10,10"
     href ="http://www.twitter.com" target ="_blank" alt="Mercury" />
</map>

Now where do I put this, cause it has to be right beneath the image, per what I have read? I cannot put it inside a tag, cause that does not work.

  • 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-05-12T16:58:39+00:00Added an answer on May 12, 2026 at 4:58 pm

    First,

    How do you create an image in Javascript?

    But on to your question…

    An image map is tied to the <img /> element, not the actual image itself. So even if you have a method for creating an image in javascript, how are you placing that image in the page?

    If the image is being pushed to the server and therefore has a URL, you could then create an img element in the DOM, and then make your image map.

    In fact, you could even have the image map before the image was ever created, since all that ties the map to the image is the attribute usemap which points to the name attribute of the map element.

    Quick Edit

    I think I understand now. The Image() method you are referring to is simply creating an img element, right?

    So basically, you just need to add the attribute/property usemap and set it to the name of the <map> you want to use.

    To use David’s method, you would go with something like:

    //This assumes the image will go in some div with the id of "image-box"
    
    var imageBox = getElementById("image-box");
    var myImage = createElement("img");
    myImage.id = "myImage";
    myImage.src = "myimage.png";
    myImage.useMap = "#myImageMap";
    imageBox.appendChild(myImage); 
    
    //Now you would need to have a map element with a name of myImageMap
    
    var myMap = createElement("map");
    myMap.name = "myImageMap";
    imageBox.appendChild(myMap);
    
    //Obviously you would want to then fill the map using the appendChild method with the area elements that make it useful...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to create a JButton with your own button graphic and
Is there any way to create a virtual drive in (My) Computer and manipulate
Is there any way to create the query parameters for doing a GET request
Is there a way to create an html link using h:outputLink, other JSF tag
Is there any way to create C# 3.0 anonymous object via Reflection at runtime
Is there a way to create an instance of a class based on the
Is there a way to create C# objects and call methods from unmanaged C++,
Is there a way to create register a handler that will be called exactly
Is there a way to create a Distinct query in HQL. Either by using
Is there a way to create a function/sub signature that accepts an arbitrary typed

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.