我爲此做了一些小動作,但找不到我在此嘗試做的確切事情。基本上我有一個圖像地圖,我想在鼠標懸停的圖像上方顯示隱藏的圖層。有5個不同的熱點和5個不同的隱藏層相對應,只有當您將鼠標懸停在相應的熱點上時纔會顯示。從透明PNG中獲取閃爍用作鼠標懸停圖像
問題是這樣的:頂部的每個隱藏層都包含一個帶有透明位的PNG,並且PNG幾乎與用戶的鼠標位於同一個位置。當它被鼠標懸停調用時,PNG會很快閃爍......我認爲,因爲頁面由於其透明度而無法確定鼠標是否在圖像上?
任何人都有一個聰明的解決方案呢?
我的頭得到這個:
<script type="text/javascript" language="JavaScript">
<!--
function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "block";
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}
//-->
</script>
這在頁面的正文:
<div id="homeowners"
style="display:none;
position:absolute;
left:0px;
top:39px;
padding: 5px;
z-index:10;">
<img src="<?php bloginfo('template_directory'); ?>/images/homeowners-over.png" width="257" height="107" alt="Homeowners" /></div>
<div id="dealers"
style="display:none;
position:absolute;
left:319px;
top:39px;
padding: 5px;
z-index:10;">
<img src="<?php bloginfo('template_directory'); ?>/images/dealers-over.png" width="257" height="107" alt="Dealers" /></div>
<div id="commercial"
style="display:none;
position:absolute;
left:0px;
top:509px;
padding: 5px;
z-index:10;">
<img src="<?php bloginfo('template_directory'); ?>/images/commercial-over.png" width="257" height="107" alt="Commercial" /></div>
<div id="importers"
style="display:none;
position:absolute;
left:319px;
top:509px;
padding: 5px;
z-index:10;">
<img src="<?php bloginfo('template_directory'); ?>/images/importers-over.png" width="257" height="107" alt="Importers" /></div>
<img src="<?php bloginfo('template_directory'); ?>/images/aww_home.jpg" width="586" height="638" border="0" usemap="#Map" />
<map name="Map" id="Map">
<area shape="poly" coords="3,4,293,4,293,25,4,313" href="#"
onmouseover="ShowContent('homeowners'); return true;"
href="javascript:ShowContent('homeowners')"
onmouseout="HideContent('homeowners'); return true;"
href="javascript:HideContent('homeowners')">
<area shape="poly" coords="296,5,583,4,584,312,296,27" href="#"
onmouseover="ShowContent('dealers'); return true;"
href="javascript:ShowContent('dealers')"
onmouseout="HideContent('dealers'); return true;"
href="javascript:HideContent('dealers')">
<area shape="poly" coords="294,32,8,317,295,603,575,318" href="#" />
<area shape="poly" coords="5,322,4,633,294,634,294,608" href="#"
onmouseover="ShowContent('commercial'); return true;"
href="javascript:ShowContent('commercial')"
onmouseout="HideContent('commercial'); return true;"
href="javascript:HideContent('commercial')">
<area shape="poly" coords="299,607,299,634,582,634,580,325" href="#"
onmouseover="ShowContent('importers'); return true;"
href="javascript:ShowContent('importers')"
onmouseout="HideContent('importers'); return true;"
href="javascript:HideContent('importers')">
</map>
非常感謝!
這並不完全符合我設置事件的方式,但我認爲您正在解決基本問題 - 我將mouseout事件附加到了錯誤的事情上。 mouseover和mouseout事件都應用於圖像UNDERNEATH上隱藏的PNG上的熱點區域。你給了我一個非常好的線索......我想我需要以某種方式設置不同的mouseout事件。我鑼去嘗試一些事情,並會回報。謝謝! – Tim 2011-06-10 19:47:06