Forum Moderators: open

Message Too Old, No Replies

Dynamicaly creating Image Maps

Simple Javascript

         

blend27

6:50 pm on Sep 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I need to to this dynamicaly:

external JS file contains a function

function addButton(a){
var btnScr = document.createElement("img");
btnScr.setAttribute('class', 'curr');
btnScr.setAttribute('src', 'images/a.gif');
btnScr.setAttribute('alt', 'change currency');
btnScr.setAttribute('usemap','#rr');
if (a==1){
document.getElementById("oDiv1").appendChild(btnScr);}
}

another External JS File contains another function

function Alerton_click(x){alert(x);}

the page itself contains image map code:

<map name="rr" id="rr">
<area shape="rect" coords="1,4,27,12" onclick="Alerton_click('Hi');" />
<area shape="rect" coords="30,4,60,15" onclick="Alerton_click('Hey');" />
</map>

the image gets displayd on the page at the position it needs to be, but image map functionality woun't work.

Am I missing something?

Thanks in advance.

Trace

7:36 pm on Sep 10, 2007 (gmt 0)

10+ Year Member



Are you calling the map properly in your IMG tag?

<img src="something.gif" width="100" height="100" usemap="#rr" />

blend27

8:41 pm on Sep 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I am trying to create image, on the fly, and use it as map.

so yes.