davelf
06-01-2011, 06:20 AM
How to play sound on mouseover?
I read a couple script, for example this one:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<!-- music start -->
<script language="javascript" type="text/javascript">
function playSound(soundfile) {
document.getElementById("dummy").innerHTML=
"<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
}
</script>
<!-- sound end -->
</head>
<body>
<p onmouseover="playSound('http://cdn.x.indowebster.com/download/5/39681f0fdaf21ed7c84bd93fbd586572.mp3');">Mouse over this text to hear a sound</p>
</body>
</html>
But still it doesn't work, is there any other example for my problem?
Thank you very much...
I read a couple script, for example this one:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<!-- music start -->
<script language="javascript" type="text/javascript">
function playSound(soundfile) {
document.getElementById("dummy").innerHTML=
"<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
}
</script>
<!-- sound end -->
</head>
<body>
<p onmouseover="playSound('http://cdn.x.indowebster.com/download/5/39681f0fdaf21ed7c84bd93fbd586572.mp3');">Mouse over this text to hear a sound</p>
</body>
</html>
But still it doesn't work, is there any other example for my problem?
Thank you very much...