播放声音文件 onMouseOver 事件 [英] playing sound file onMouseOver event

查看:41
本文介绍了播放声音文件 onMouseOver 事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的声音文件在鼠标悬停在我的图像上时播放.我的代码无法正常工作,任何人都可以提供帮助,如果有人这样做,请提前告诉我代码.谢谢

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>

推荐答案

经过我测试的工作良好的代码你在转义字符中犯了一个错误嵌入

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>

这篇关于播放声音文件 onMouseOver 事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆