Image Map not working in Firefox! works fine in Chrome+Safari

时间:2022-10-07 16:26:55

Ive made a image map and its not working in firefox. It works fine in both Chrome and Safari.

我做了一个图像映射,它不能在Firefox中工作。它适用于Chrome和Safari。

This is the site bryanedwardcollins.com

这是网站bryanedwardcollins.com

Please help!

请帮忙!

    <MAP NAME="menumap" >
<AREA 
HREF="contact.html" ALT="contact" 
SHAPE="POLY" COORDS="425,100, 572,89, 594,142, 488,150, 460,166, 423,100">
    <AREA
    HREF="insameit.html" ALT="insame i.t." 
    SHAPE="POLY" COORDS="382,239, 462,245, 461,343, 608,344, 610,395, 354,405, 354,341">
    <AREA
    HREF="floorpart.html" ALT="floor part" 
    SHAPE="POLY" COORDS="307,185, 429,185, 430,221, 379,222, 374,235, 283,224">
    <AREA
    HREF="iouse.html" ALT="I O Use" 
    SHAPE="POLY" COORDS="27,18, 231,16, 243,0, 382,0, 253,265, 69,252, 193,73, 27,73">
    <AREA
    HREF="worldpart.html" ALT="world part" 
    SHAPE="POLY" COORDS="25,303, 122,305, 122,448, 27,449">
    </MAP>

2 个解决方案

#1


21  

I stumbled into this issue as well. It seems that Chrome will parse the img attribute usemap="mapName" without the # symbol. However, if you don't include the hash symbol '#', the map will not be associated with the image on FireFox and Internet Explorer.

我也偶然发现了这个问题。 Chrome似乎会解析没有#符号的img属性usemap =“mapName”。但是,如果您不包含井号'#',则地图将不会与FireFox和Internet Explorer上的图像相关联。

Here is the correct way to do it:

这是正确的方法:

<img src="images/header.jpg" id="hdr" name="hdr" usemap="#hdrMap" alt="alt string here" border="0">
    <map name="hdrMap" style="cursor:pointer;">
        <area shape="rect" coords="720,65,880,0" href="http://www.thisisthefirstlink.com" target="_blank" alt="first link alt">
        <area shape="rect" coords="882,65,1024,0" href="http://www.secondlink.com" target="_blank" alt="second link alt">
    </map>

Notice the usemap="#hrdMap" has a hash tag symbol and matches the name="hdrMap" attribute for the map tag. This can seem a little confusing because a lot of people associate the # symbol with referencing an id attribute.

请注意,usemap =“#hrdMap”具有哈希标记符号,并匹配地图标记的name =“hdrMap”属性。这看起来有点令人困惑,因为许多人将#符号与引用id属性相关联。

Hope this helps

希望这可以帮助

#2


3  

Another <map issue in Firefox and solution to it - make sure you're not using any anchor(<a>) elements inside <map>. If <map> has any <a> children Firefox will ignore whole <map> element.

Firefox中的另一个 中使用任何锚点( )元素。如果有任何 孩子,Firefox将忽略整个元素。 问题及其解决方案>

It might be obvious not to use <a> elements because <area> has href attribute, but, for example, in Ember.js it was useful to me, to write code like that:

显然不使用元素因为具有href属性,但是,例如,在Ember.js中,编写这样的代码对我很有用:

<map id='human-image-map' name='human-image' action='showTooltip'>
    <section class="front" title="Pokaż ćwiczenia">
      {{#link-to 'training.shoulders'}}
        <area alt="Barki" shape="poly" coords="39,74,37,75,35,77,33,78,32,76,32,73,32,71,32,68,33,65,33,63,34,61,36,58,37,56,38,54,40,53,42,52,44,51,46,51,48,51,51,50,55,49,57,48,59,47,61,47,59,50,58,52" />
        <area alt="Barki" shape="poly" coords="112,74,114,75,117,77,119,79,121,77,121,74,121,71,121,68,119,65,117,62,116,59,113,57,111,54,109,53,106,51,103,50,99,49,96,47,93,46,90,45,90,48,92,50,93,52,95,54,97,56,99,59,101,62,103,65,106,68" />
      {{/link-to}}
    </section>
</map>

I can't specify href attribute manually, it's considered best practice to leave this to link-to helper.

我无法手动指定href属性,将其保留为link-to helper是最佳做法。

Solution to my specific Ember.js problem was just using another tag instead of <a>. So, adding tagName='span' to link-to helper solved my issue:

解决我的特定Ember.js问题只是使用另一个标签而不是。因此,将linkName ='span'添加到link-to helper解决了我的问题:

{{#link-to 'training.shoulders' tagName='span'}}
  <!-- ... -->
{{/link-to}}

Note: In Chrome <a> elements inside <map> just work fine.

注意:在Chrome中<<>中的元素正常工作。

#1


21  

I stumbled into this issue as well. It seems that Chrome will parse the img attribute usemap="mapName" without the # symbol. However, if you don't include the hash symbol '#', the map will not be associated with the image on FireFox and Internet Explorer.

我也偶然发现了这个问题。 Chrome似乎会解析没有#符号的img属性usemap =“mapName”。但是,如果您不包含井号'#',则地图将不会与FireFox和Internet Explorer上的图像相关联。

Here is the correct way to do it:

这是正确的方法:

<img src="images/header.jpg" id="hdr" name="hdr" usemap="#hdrMap" alt="alt string here" border="0">
    <map name="hdrMap" style="cursor:pointer;">
        <area shape="rect" coords="720,65,880,0" href="http://www.thisisthefirstlink.com" target="_blank" alt="first link alt">
        <area shape="rect" coords="882,65,1024,0" href="http://www.secondlink.com" target="_blank" alt="second link alt">
    </map>

Notice the usemap="#hrdMap" has a hash tag symbol and matches the name="hdrMap" attribute for the map tag. This can seem a little confusing because a lot of people associate the # symbol with referencing an id attribute.

请注意,usemap =“#hrdMap”具有哈希标记符号,并匹配地图标记的name =“hdrMap”属性。这看起来有点令人困惑,因为许多人将#符号与引用id属性相关联。

Hope this helps

希望这可以帮助

#2


3  

Another <map issue in Firefox and solution to it - make sure you're not using any anchor(<a>) elements inside <map>. If <map> has any <a> children Firefox will ignore whole <map> element.

Firefox中的另一个 中使用任何锚点( )元素。如果有任何 孩子,Firefox将忽略整个元素。 问题及其解决方案>

It might be obvious not to use <a> elements because <area> has href attribute, but, for example, in Ember.js it was useful to me, to write code like that:

显然不使用元素因为具有href属性,但是,例如,在Ember.js中,编写这样的代码对我很有用:

<map id='human-image-map' name='human-image' action='showTooltip'>
    <section class="front" title="Pokaż ćwiczenia">
      {{#link-to 'training.shoulders'}}
        <area alt="Barki" shape="poly" coords="39,74,37,75,35,77,33,78,32,76,32,73,32,71,32,68,33,65,33,63,34,61,36,58,37,56,38,54,40,53,42,52,44,51,46,51,48,51,51,50,55,49,57,48,59,47,61,47,59,50,58,52" />
        <area alt="Barki" shape="poly" coords="112,74,114,75,117,77,119,79,121,77,121,74,121,71,121,68,119,65,117,62,116,59,113,57,111,54,109,53,106,51,103,50,99,49,96,47,93,46,90,45,90,48,92,50,93,52,95,54,97,56,99,59,101,62,103,65,106,68" />
      {{/link-to}}
    </section>
</map>

I can't specify href attribute manually, it's considered best practice to leave this to link-to helper.

我无法手动指定href属性,将其保留为link-to helper是最佳做法。

Solution to my specific Ember.js problem was just using another tag instead of <a>. So, adding tagName='span' to link-to helper solved my issue:

解决我的特定Ember.js问题只是使用另一个标签而不是。因此,将linkName ='span'添加到link-to helper解决了我的问题:

{{#link-to 'training.shoulders' tagName='span'}}
  <!-- ... -->
{{/link-to}}

Note: In Chrome <a> elements inside <map> just work fine.

注意:在Chrome中<<>中的元素正常工作。