Forum Moderators: open

Message Too Old, No Replies

IE issue

         

stuckinbed

7:01 pm on Mar 26, 2006 (gmt 0)

10+ Year Member



Greetings,

I wrote some code that creates popup-tooltips on an image map. Below is the code, which is working fine in firefox, but nothing happens in IE (not even an error message). Any ideas? Am I using a function that's not recognized in IE?

function addEvent(elm, evType, fn, useCapture)
// cross-browser event handling for IE5+, NS6+ and Mozilla
// By Scott Andrew
{
if (elm.addEventListener) {
elm.addEventListener(evType, fn, useCapture);
return true;
} else if (elm.attachEvent) {
var r = elm.attachEvent('on' + evType, fn);
return r;
} else {
elm['on' + evType] = fn;
}
}

function popup(e) {
if (window.event) {
var obj = window.event.srcElement;
} else {
var obj = e.target;
}
var popup = document.createElement('div');
popup.className = 'popup';
popup.id = 'popup';
var popup_tn = document.createTextNode(obj.title);
popup.appendChild(popup_tn);
document.getElementById('map').appendChild(popup);
popup.style.display = 'block';
}

function hide() {
var popup = document.getElementById('popup');
popup.style.display = 'none';
}

function addListeners() {
addEvent(document, 'mouseover', popup, false);
addEvent(document, 'mouseout', hide, false);
}

document.onload = addListeners();

stuckinbed

7:18 am on Mar 28, 2006 (gmt 0)

10+ Year Member



WHEW i solved it

Go figure; the problem had NOTHING to do with the javascript. It was the following line of code in the html:

<img src="image.png" ismap="ismap" usemap="map">

This is the code for the image associated with the image map. Turns out this won't work in IE unless you have a pound ('#') sign just before the value in the 'usemap' attribute

In other words, the code should look like this:

<img src="image.png" ismap="ismap" usemap="#map">

Hope that helps somebody out in the future who was pulling their hair out like I was.