重要なお知らせ

「教えて! goo」は2025年9月17日(水)をもちまして、サービスを終了いたします。詳細はこちら>

電子書籍の厳選無料作品が豊富!

サイドメニューをonmouseoverした時と、onclickした時に別々の音を付けたいです。
なかなかうまくいかないので、質問しました。
下記のコードをどうすればよいのでしょうか?

<?xml version="1.0" encoding="Shift_JIS">
<!DOCUTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml/DTD/xhtm1-strict.dtd">
<head>
<meta http-equiv="Content-Type" content=text/css; charset="Shift_JIS" />
<meta http-equiv="Content-Script-Type" content="text/javascript">
<link rel="stylesheet" href="style.css" type="text/css" />
<script language="JavaScript" type="text/javascript">
function playSound(soundfile) {
document.getElementById("img/shake.wav").innerHTML=
"<embed src="img/shake.wav"+soundfile+"img/shake.wave" hidden="true" autostart="false" loop="false" />";
}
</script>

<title>2012 Backgammon Festival</title>
</head>
<body>
<div class="main">
<a href="home.html"><img src="img/title.gif"></a>
<h1>aaa</h1>
<p>aaa</p>
</div>
<div class="menu">
<a href="greeting.html" onclick="sound(this)" title="img/roll.wav"><img src="img/greeting.gif" onmouseover="this.src='img/z_greeting.gif'" onmouseover="playSound('roll.wav')" onmouseout="this.src='img/greeting.gif'" alt="ご挨拶"></a><br>

</div>
</body>
</html>

A 回答 (1件)

こんにちは。



ざっと見てみましたが、1点ほど気になる部分がありました。


<img src="img/greeting.gif" onmouseover="this.src='img/z_greeting.gif'" onmouseover="playSound('roll.wav')" onmouseout="this.src='img/greeting.gif'" alt="ご挨拶">
の部分ですが、
1つのタグ内にonmouseoverが2つあるので、
onmouseover="this.src='img/z_greeting.gif'; playSound('roll.wav');"
とした方がよろしいかと思います。
    • good
    • 0
この回答へのお礼

ありがとうございます!
むー、なるほど・・です。

お礼日時:2012/08/31 17:32

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!