我使用了我的网站上的菜单中的JavaScript onmouseover事件,但是当我宣布一个DOCTYPE它不工作在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

编辑。通知优良奔空白”评论说,由于某种原因,在后WMD将无法正确显示。

其他提示

好大我得到它使用JavaScript。我必须说,我与这个社会如此深刻的印象,感谢你的帮助。现在,我要学会做正确的方式。)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top