admin管理员组文章数量:1401826
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>
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>
Share
Improve this question
edited Apr 21, 2011 at 18:22
Naftali
146k41 gold badges247 silver badges304 bronze badges
asked Apr 21, 2011 at 18:20
Fawad GhafoorFawad Ghafoor
6,2277 gold badges43 silver badges54 bronze badges
2 Answers
Reset to default 4<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.
Working fine code tested by me You did a mistake in escape characters in embed
<html>
<head>
<script language="javascript" type="text/javascript">
function Sound(surl) {
alert("working");<!-- this will ensure function is called successfully-->
document.getElementById("myspan").innerHTML=
"<embed src=\""+surl+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
}
</script>
</head>
<body>
<span id="myspan"></span>
<form>
<img src="imag.jpg" onMouseOver="Sound('success.wav')" />
</form>
</span>
</body>
</html>
本文标签: javascriptplaying sound file onMouseOver eventStack Overflow
版权声明:本文标题:javascript - playing sound file onMouseOver event - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744313044a2600123.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论