Log in

View Full Version : How play sound on mouseover



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...

Beverleyh
06-01-2011, 02:08 PM
Maybe this will help: http://www.dynamicdrive.com/forums/showthread.php?t=49395

You can attach a SoundManager2 event to mouseover as well as onclick

davelf
06-02-2011, 09:47 AM
Thx Beverleyh

You solve my problem..:D