2013-04-04 25 views
3

上我有一個大的圖像與HTML <map>,我想跳轉到一個特定區域的形象上。我已經使用了<area />標籤用於標記的位置跳轉到指定的位置的圖像映射

的代碼看看:

<img src="demo_files/k3.png" id="target" alt="Map" usemap="#powerpuffgirls" /> 
<map name="powerpuffgirls"> 
    <area shape="rect" coords="624,137,671,167" href="#" id="ppg" title="The Powerpuff Girls" alt="The Powerpuff Girls" /> 
    <area shape="rect" coords="99,2685,161,2723" href="#" name="ppg1" title="The Powerpuff Gidrls" alt="The Powerpuff sGirls" /> 
</map> 

然而,我無法移動到任何區域的圖像上。

編輯:任何其他方法移動到圖像的特定區域將是偉大的!

+0

是比顯示器的屏幕分辨率越大......? – SaurabhLP 2013-04-04 06:28:58

+0

@SaurabhLP是的,頁面顯示兩個滾動條! – Krishna 2013-04-04 06:36:00

回答

6

試試這個link

$('a.links').click(function(e){ 
    e.preventDefault(); 
    var coor = $(this.hash).attr('coords').split(','); 
    $('html,body').scrollTo(coor[0], coor[1]); 
}); 

我已經使用這個插件scrollTo

腳本將防止標籤的缺省功能,將得到的座標與從href屬性標識的區域標籤屬性和計算的位置和滾動到位置

0

入住這演示我創建...

嘗試導航通過ID領域...

<div><a href="#ppg">Go to one</a> <a href="#ppg1">Go to two</a></div> 

你必須與該地區發揮它的座標...

http://jsfiddle.net/D9W6C/

+0

感謝您的回答,但您可以在您的示例中看到該頁面在同一位置上移動,無論區域中給出的座標如何。 – Krishna 2013-04-04 07:04:15