Dynamic image maps broken uder IE8-Beta? (with sample page)

  • Thread starter Jeremy J Starcher
  • Start date
J

Jeremy J Starcher

Are dynamic image maps broken under IE8-Beta or am I missing something
obvious?

<URL: http://parts.mopedepot.com/brokenie.html >

Tested and found working under IE6, IE7, Fx 2, Fx 3 (Beta)

Is this something I should worry about, or should I delay my panic until
IE8 final comes out?

(Posted in c.l.js five days ago with no answer. Seeing if a different
audience has experience.)
 
J

Jeremy J Starcher

What is the difference between a dynamic image map and one that is not
dynamic?

In this context, I was using "dynamic" in the sense of "dynamic HTML."

Under IE8, if I have an AREA defined in my HTML then I can attach an
onclick handler, and it will work.

If I create an AREA tag and append it to my MAP structure, then the
attached onclick handler will do nothing.

On every other browser that I have tested (including IE5.5, 6 and 7, Fx2,
Opera 9, Safari and Konq) both methods have a functional onclick handler.
 
N

Nik Coughlin

Jeremy J Starcher said:
Are dynamic image maps broken under IE8-Beta or am I missing something
obvious?

<URL: http://parts.mopedepot.com/brokenie.html >

Tested and found working under IE6, IE7, Fx 2, Fx 3 (Beta)

Is this something I should worry about, or should I delay my panic until
IE8 final comes out?

(Posted in c.l.js five days ago with no answer. Seeing if a different
audience has experience.)

JavaScript is heavily broken in IE8. Try visiting Google Maps or even some
of Microsoft's own sites like Live Maps. It will be fixed before the
release, it would be suicide for them not to.
 
J

Jeremy J Starcher

JavaScript is heavily broken in IE8. Try visiting Google Maps or even
some of Microsoft's own sites like Live Maps. It will be fixed before
the release, it would be suicide for them not to.

Thanks for the heads up.

I've only used IE8 in a [slow] virtual machine here, so its been too
painful to test on any other site than my own.

I'll put it on the back burner and tell the folks who are using IE8 that
its a) broken and b) their fault for using a beta with no other plan.
They can drop back to the IE7 engine if they need.
 
G

GTalbot

Under IE8, if I have an AREA defined in my HTML then I can attach an
onclick handler, and it will work.

If I create an AREA tag and append it to my MAP structure, then the
attached onclick handler will do nothing.

On every other browser that I have tested (including IE5.5, 6 and 7, Fx2,
Opera 9, Safari and Konq) both methods have a functional onclick handler.

This will work in IE 8 beta 1 with DOM 2 HTML methods instead of using
setAttribute. I have made a few changes from your testpage though:

<script type="text/javascript">
function appendAreaToMap()
{
var DynamicallyDOMInsertedmapArea = document.createElement("area");
DynamicallyDOMInsertedmapArea.shape = "circle";
DynamicallyDOMInsertedmapArea.noHref = "";
DynamicallyDOMInsertedmapArea.coords = "70, 84, 51";
DynamicallyDOMInsertedmapArea.id = "dynamic";
DynamicallyDOMInsertedmapArea.onclick = function(evt)
{
alert("You clicked on the weird D");
};

document.getElementById("mymap").appendChild(DynamicallyDOMInsertedmapArea);

var el=document.getElementById("test1");

el.onclick = function(evt)
{
alert("You clicked HTML station");
};
}
</script>
</head>

<body onload="appendAreaToMap();">

(...)

<p><img src="WeirdImageMapForTestingIE8.gif" width="500"
height="300" alt="Image download support must be enabled for this
test" usemap="#mymap">
<map id="mymap" name="mymap">
<area id="test1" shape="rect" coords="25, 180, 125, 280"
nohref="nohref" alt="">
<area shape="poly" coords="153, 106, 186, 225, 340, 193, 315, 81,
304, 167" nohref alt="">
<area shape="rect" coords="420, 19, 478, 278" nohref="nohref"
alt="">
</map>
</p>

Changes I made:
- I inserted the map inside the <p>, not creating another <p>.
- I also renamed several objects: function names, image filenames,
etc.
- I removed setAttribute everywhere and used instead DOM 2 HTML
methods:
http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26019118
- style="cursor: pointer;" removed
- event replaced by evt; it could be removed entirely
- ismap removed

A few more aspects of the testpage could still be improved: like
testing support for createElement and getElementById before calling
them.

Regards, Gérard
 
J

Jeremy J Starcher

This will work in IE 8 beta 1 with DOM 2 HTML methods instead of using
setAttribute. I have made a few changes from your testpage though:

[ Sample snipped ]
Changes I made:
- I inserted the map inside the <p>, not creating another <p>. - I also
renamed several objects: function names, image filenames, etc.

*nods* I was just trying to keep it simple there.
- I removed setAttribute everywhere and used instead DOM 2 HTML methods:
http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26019118

That is the magic. I have no idea why that didn't cross my mind. So I
guess I was doing something stupid.
- style="cursor: pointer;" removed
- event replaced by evt; it could be removed entirely - ismap removed

I'll do a bit of reading, try to figure out why you would have removed
'ismap'.
A few more aspects of the testpage could still be improved: like testing
support for createElement and getElementById before calling them.

Of course, of course!

Those tests should be in my production code. I'll double check I rolled
those changes out.
Regards, Gérard

A dozen thanks.

I'm wearing a dozen hats here at work, but I've got your message saved
for the next time I wear my webdev one.
 
P

poizn99

Hi all.

Iv been stuck on a similar problem for a while now, and stumbled upon
this. I was really glad that other people had similar problems, but
unfortunately my problem is not yet solved...

This is a simple page I created that adds an image, map tag and an
area to the body of the page. It also adds an onmouseover even to the
area, which will alert('1');
The page is really simple, and works great in FF, but not in IE.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript">
function add_event(obj , event_type , func) {
  if(obj.addEventListener) {
    obj.addEventListener(event_type , func , false);
    return true;
  } else if(obj.attachEvent) {
    var r = obj.attachEvent("on" + event_type , func);
    return r;
  } else {
    return false;
  }
}

function africa_toggle() {
  alert('1');
}

function loader() {
  var map_img = document.createElement("img");
  map_img.src = "world_map.jpg";
  map_img.id = "search_map";
  map_img.alt = "World Map";
  map_img.border = "0";
  // next line doesnt work if I use the above notation... so I had to
use setAttribute
  map_img.setAttribute("usemap" , "#search_map_map");

  var map_tag = document.createElement("map");
  map_tag.name = "search_map_map";
  map_tag.id = "search_map_map";

  var area = document.createElement("area");

  area.id = "africa";
  area.shape = "poly";
  area.coords =
"208,171,220,169,227,162,230,156,230,149,238,142,238,134,236,130,239,122,251,110,252,100,245,102,239,98,232,87,226,77,222,72,215,71,210,72,202,69,197,63,185,66,179,67,174,70,172,75,165,79,164,85,165,91,164,96,167,103,174,112,178,109,181,112,188,108,194,110,197,112,198,115,197,118,200,126,203,128,204,134,203,139,201,143,204,152,206,160,208,163";
  area.href = "africa.php";

  add_event(area , "mouseover" , africa_toggle);

  map_tag.appendChild(area);

  document.getElementById("body").appendChild(map_img);
  document.getElementById("body").appendChild(map_tag);
}

add_event(window , "load" , loader);
</script>
</head>
<body id="body">

</body>
</html>

Is this another IE bug (ps im using IE7) or does anyone have some info
for me?
Please help (please)
Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top