Javascript – playing sound file onMouseOver event

htmljavascriptxhtml

i want my sound file to play when some over mouse on my image.my code is not working any one can help,if some 1 did this plz let me know the code.thanx in advance

function Sound(surl) {
  document.getElementById("myspan").innerHTML=
    "<embed src='"+surl+"' hidden=true autostart=true loop=false>";
}


<span id=myspan></span>
<form>
<img src="imag.jpg" onMouseOver="Sound('success.wav')" />
</form>

Best Solution

<html>
<head>
<script type="text/javascript">
    function sound(surl) {
        document.getElementById("myspan").innerHTML =
        "<embed src="+surl+" hidden=true autostart=true loop=false>";
    }
</script>
</head>
<body>

<span id="myspan"></span>

<form>
    <img src="image.jpg" onmouseover="sound('success.wav')" />
</form>

</body>
</html>

This has been tested and is working. May just want to change the cursor when you mouse over in CSS.