Click to See Complete Forum and Search --> : Displaying text over image in IE


Norm
10-31-2009, 10:41 AM
Hi,
I'm trying to create an HTML page that displays an image and will display a small text at the location the mouse is clicked. I've gotten it to work with Firefox but am unable to get it to work with IE.

After I determine the text I want to display (its in NamesList[]) at the clicked location I use the following Javascript code:

var aDiv = document.createElement('div');
aDiv.setAttribute("id", LayerNm + divCnt++);
// Display the name at the upper left of rectangle given in NamesList[]
var absPt = relToAbs(NamesList[ix+dX], NamesList[ix+dY]); // get absolute point location
aDiv.setAttribute("style", 'position:absolute;left:' + absPt.x + 'px;top:'
+ absPt.y + 'px;font-weight:bold;color:cyan');
aDiv.appendChild(document.createTextNode(NamesList[ix+dName]));
aDiv.onmousedown = myMouseDown; // set for new div

imgDiv.parentNode.insertBefore(aDiv, imgDiv); // works!!!

Definitions from other parts of code:

imgDiv = document.getElementById('Image'); // set global one time here
...
<CENTER><IMG SRC="1990_Reunion-300_ED1.jpg" HEIGHT="96%" ALT="1990 Reunion" id="Image"></CENTER>
...


Works in Firefox, but not in IE.
Is there code that will work in both browsers?
Is there code that will work in IE that I can chose if in IE?

Thanks,
Norm