Dear all,
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.