【问题标题】:The href links in my html code won't work.我的 html 代码中的 href 链接不起作用。
【发布时间】:2017-12-22 13:59:30
【问题描述】:

我用 HTML 写了一个简单的网页:

<!DOCTYPE html>
<html>
<body>

<img src="http://media.web.britannica.com/eb-media/59/89959-050-6CC4DDA1.jpg" alt="WorldMap" usemap="#Map" />
<map name="WorldMap" id="Map">
    <area alt="NorthAmerica" title="" href="www.google.com" shape="rect" coords="307,181,488,250" />
    <area alt="SouthAmerica" title="" href="www.google.com" shape="rect" coords="468,504,636,432" />
    <area alt="Europe" title="" href="www.google.com" shape="rect" coords="853,147,1005,180" />
    <area alt="Africa" title="" href="www.google.com" shape="rect" coords="964,350,826,383" />
    <area alt="Asia" title="" href="www.google.com" shape="rect" coords="1115,232,1221,193" />
    <area alt="Australia" title="" href="www.google.com" shape="rect" coords="1270,564,1483,532" />
    [...]
</map>


</body>
</html>

它返回一张世界地图,并且应该为每个大陆创建一个链接。

但是,链接不响应点击。

可能是什么问题?

【问题讨论】:

    标签: html image href


    【解决方案1】:

    您的usemap="#WorldMap" 必须与name 标记匹配。不是身份证。

    像这样:

    <img src="http://media.web.britannica.com/eb-media/59/89959-050-6CC4DDA1.jpg" alt="WorldMap" usemap="#WorldMap" />
    <map name="WorldMap" id="Map">
        <area alt="NorthAmerica" title="" href="/#" shape="rect" coords="307,181,488,250" />
        <area alt="SouthAmerica" title="" href="/#" shape="rect" coords="468,504,636,432" />
        <area alt="Europe" title="" href="/#" shape="rect" coords="853,147,1005,180" />
        <area alt="Africa" title="" href="/#" shape="rect" coords="964,350,826,383" />
        <area alt="Asia" title="" href="/#" shape="rect" coords="1115,232,1221,193" />
        <area alt="Australia" title="" href="/#" shape="rect" coords="1270,564,1483,532" />
    </map>

    【讨论】:

      【解决方案2】:

      如果您要链接到站外资源,您的链接必须包含http:// 或https:// 前缀。

      这意味着你需要:

      <area alt="NorthAmerica" title="" href="http://www.google.com" shape="rect" coords="307,181,488,250" />
      

      虽然您可能会将其设为更具体的链接。

      【讨论】:

      • 认为这不是当前的问题......它仍然可以点击并且无论如何都会出现手形光标。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-05
      相关资源
      最近更新 更多