[英]Javascript onmouseover not working with doctype in firefox?
我在網站上的菜單上使用了JavaScript onmouseover事件,但是在聲明文檔類型時在firefox中不起作用。 如果我不聲明doctype,IE會顯示錯誤的頁面。 這是我使用的方法。
loadImage1 = new Image();
loadImage1.src = "http://broken.gif";
staticImage1 = new Image();
staticImage1.src = "http://broken.gif";
loadImage2 = new Image();
loadImage2.src = "http://broken.gif";
staticImage2 = new Image();
staticImage2.src = "http://broken.gif";
loadImage3 = new Image();
loadImage3.src = "http://broken.gif";
staticImage3 = new Image();
staticImage3.src = "http://broken.gif";
function showa() {
image1.src=loadImage1.src;
}
function hidea() {
image1.src=staticImage1.src;
}
function showb() {
image2.src=loadImage2.src;
}
function hideb() {
image2.src=staticImage2.src;
}
function showc() {
image3.src=loadImage3.src;
}
function hidec() {
image3.src=staticImage3.src;
}
在體內:
<a href="http://broken.html" onMouseOver="showa()" onmouseout="hidea()">
<img name="image1" src="http://broken.gif" alt="Browse" width="193" height="47" border="0" />
</a>
<a href="http://broken.html" onmouseover="showb()" onmouseout="hideb()">
<img name="image2" src="http://broken.gif" width="193" height="47" alt="Make a List" border="0" />
</a>
<a href="http://broken.html" onmouseover="showc()" onmouseout="hidec()">
<img name="image3" src="http://broken.gif" width="193" height="47" alt="Requests" border="0" />
</a>
</div>
<div id="searchbar">
<img src="..broken.gif" width="222" height="41" />
<img src="..broken.gif" width="108" height="41" alt="Search" />
Firefox不喜歡您通過名稱引用圖像的方式。 請改用Id和getElementById。
編輯。 注意出色的Ben Blank的評論,由於某種原因,WMD無法正確顯示在帖子中。
好的,很好,我使用了javascript。 我不得不說我對這個社區印象深刻,感謝您的所有幫助。 現在,我將學習正確的方法;)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.