function menuhover(id,state){
if(id=="home"){
if(state=="over"){
document.getElementById(id).src="pages/styles/images/home1hover.png";
} else if(state=="out"){
document.getElementById(id).src="pages/styles/images/home1.png";
}
} else if(id=="news"){
if(state=="over"){
document.getElementById(id).src="pages/styles/images/news2hover.png";
} else if(state=="out"){
document.getElementById(id).src="pages/styles/images/news2.png";
}
} else if(id=="register"){
if(state=="over"){
document.getElementById(id).src="pages/styles/images/register3hover.png";
} else if(state=="out"){
document.getElementById(id).src="pages/styles/images/register3.png";
}
} else if(id=="contrib"){
if(state=="over"){
document.getElementById(id).src="pages/styles/images/contributor4hover.png";
} else if(state=="out"){
document.getElementById(id).src="pages/styles/images/contributor4.png";
}
} else if(id=="login"){
if(state=="over"){
document.getElementById(id).src="pages/styles/images/login5hover.png";
} else if(state=="out"){
document.getElementById(id).src="pages/styles/images/login5.png";
}
}
}
<div class="menu">
<img class="banner" src="pages/styles/images/banner.png" border="0"/>
<p class="link"><a href="http://www.realmsofruin.co.cc"><img id="home" src="pages/styles/images/home1.png" border="0" onmouseover="menuhover(home,over)" onmouseout="menuhover(home,out)"/></a></p>
<p class="link"><a href=""><img id="news" src="pages/styles/images/news2.png" border="0" onmouseover="menuhover(news,over)" onmouseout="menuhover(news,out)"/></a></p>
<p class="link"><a href=""><img id="register" src="pages/styles/images/register3.png" border="0" onmouseover="menuhover(register,over)" onmouseout="menuhover(register,out)"/></a></p>
<p class="link"><a link=""><img id="contrib" src="pages/styles/images/contributor4.png" border="0" onmouseover="menuhover(contrib,over)" onmouseout="menuhover(contrib,out)"/></a></p>
<p class="link"><a link=""><img id="login" src="pages/styles/images/login5.png" border="0" onmouseover="menuhover(login,over)" onmouseout="menuhover(login,out)"/></a></p>
</div>
引用和錯誤控制檯告訴我這
在沒有定義出來沒有定義 ..
我應該如何界定呢? ?
你在代碼中調用函數時是否傳遞了狀態變量? – yoda 2009-09-07 07:10:24
這個問題沒有更好的標題嗎? – random 2009-09-07 07:15:29
好的,這是一個鏡頭:定義的JavaScript變量/參數顯然沒有定義,有什麼問題? – random 2009-09-07 07:23:56