2017-07-17 251 views
1

我在HTML写的简单网页:我的html代码中的href链接不起作用。

<!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> 

它返回世界地图,并应建立一个链接各大洲。

但是,链接不响应点击。

可能是什么问题?

回答

3

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

这意味着你需要:

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

虽然想必你会做出一个更具体的环节。

+0

这就是手头没有想到这个问题......它仍然是可以点击的,不管一个手形光标会出现。 – Miro

5

您的usemap="#WorldMap"必须与name标签匹配。不是ID。

像这样:

<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>