0
這是一個很長的頁面,所以我會附上完整的文檔,但在此總結。我有一系列地圖元素,點擊時應該激活一個描述頁面。相關的代碼是:點擊功能不會執行
<map id="mapg0" onclick="showPanel('pecheislandrear')" style="position:fixed; z:2">
<area shape="poly" coords="11,13,13,11,14,11,14,3,12,1,11,0,3,0,1,2,0,3,0,11,2,13,3,14,11,14" alt="" title="Peche Island Rear Range" id="mapg0_1">
</map>
<img alt="Peche Island Rear Range" onclick="showPanel('pecheislandrear')" usemap="#mapg0" src="LakeErie1_files/reddot.png" id="imageg0" style="position:absolute; z:1; left:210.258015267px; top:348.347527764px; width:14px;height:14px;">
<map id="mapg1" onclick="showPanel('stclairflatsfront')" style="position:fixed; z:2">
<area shape="poly" coords="11,13,13,11,14,11,14,3,12,1,11,0,3,0,1,2,0,3,0,11,2,13,3,14,11,14" alt="" title="St. Clair Flats front Range" id="mapg1_1">
展會面板功能:
function showPanel (panelId)
{
document.getElementById(panelId).style.visibility = 'visible';
}
即使我插入在這個開始的「警報」對話框,警告不顯示。但是,如果我替換
<map id="mapg0" onclick="alert ('pecheislandrear')"
我得到警報,所以「onclick」正在採取行動。另一塊這是我希望激活的面板:
<div id="pecheislandrear" class="panelHidden" style="position:fixed;left:50%;margin-left:-136px;top:50%;margin-top:-211px;
z:1;width:272px;height:422px;">
<div id="panel0" style="position:absolute;left:0px;top:12px;width:272px;
height:54px;overflow:hidden;">
<p class="Body panelP-5"><span class="panelTitle">Peche Island Rear Range</span></p>
</div>
<div style="position:absolute;left:24px;top:229px;width:232px;height:136px;overflow:hidden;">
<p class="Normal"><span class="panelDesc">Range lights were
established off Peche island in 1898. Pile clusters, they were
repeatedly swept away by ice until 1908 when they were replaced by
permanent iron and steel structures on cribs. An explosion destroyed the
front range in 1927, and the rear range was leaning so badly it was
replaced with a modern structure in 1983. The tower was moved to Marine
City where it can now be seen on the waterfront.</span></p>
</div>
<a onclick="var w = window.open(this.href,'_blank','width=1400,directories=yes,location=yes,menubar=yes,resizable=no,
scrollbars=yes,status=yes,toolbar=yes'); if(w != null){ w.focus(); }; return false;" href="http://www.lighthousefriends.com/light.asp?ID=165" target="_blank" class="panelOBJ-12 ActiveButton buttonHeight" style="position:absolute;left:84px;top:372px;width:104px;height:21px;">
<span>Learn More</span>
</a>
<img alt="photo" src="LakeErie1_files/pecherear.jpg" onclick="hidePanels()" style="position:absolute;z:2;left:38px;top:73px;width:201px;height:151px;">
</div>
整個htm被附上以供審查。 enter link description here我將不勝感激指導。一個只有2個對象的測試案例工作。更長的情況下68並沒有,我一直無法辨別差異。
你的在線html適合我!我可以點擊所有的項目和彈出的輔助警報! – Jeff
,但通過審查您的代碼,只是一個小提示:爲您的隱藏功能看看這個:http://www.w3schools.com/jsref/met_document_getelementsbyclassname.asp – Jeff
而不是警報嘗試console.log(panelId)在你的showPanel函數的開始。這對調試更好。 – Eterm