2017-07-17 256 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>