如何让我的Javascript蜂鸣声? [英] How do I make Javascript beep?
本文介绍了如何让我的Javascript蜂鸣声?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想只要用户超过我的 textarea的字符数上限发出蜂鸣声,我的网页
。
解决方案
这是不可能直接在JavaScript中执行。你需要嵌入在HTML短WAV文件,然后播放通过code。
下面是为例此页面(略清理)。
<脚本>
函数PlaySound(soundObj){
VAR声音=的document.getElementById(soundObj);
sound.Play();
}
< / SCRIPT>&所述;嵌入SRC =success.wav自动启动=假宽度=0高度=0的id =Sound1例子
enablejavascript =真正的>
您会再从JavaScript code这样称呼它
PlaySound(Sound1例子);
这应该做的正是你想要的 - 你只需要找到/创建蜂鸣声自己,这应该是微不足道的。
。I want my web page to beep whenever a user exceeds the maximum character limit of my textarea
.
解决方案
It's not possible to do directly in JavaScript. You'll need to embed a short WAV file in the HTML, and then play that via code.
Here is an example from this page (cleaned up slightly).
<script>
function PlaySound(soundObj) {
var sound = document.getElementById(soundObj);
sound.Play();
}
</script>
<embed src="success.wav" autostart="false" width="0" height="0" id="sound1"
enablejavascript="true">
You would then call it from JavaScript code as such:
PlaySound("sound1");
This should do exactly what you want - you'll just need to find/create the beep sound yourself, which should be trivial.
这篇关于如何让我的Javascript蜂鸣声?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文