admin管理员组文章数量:1308604
I found the following answer, but it does not seem to work in an HTML page:
console.log('\u0007');
How I trigger the "System Bell" in nodejs
Is there a way to ring the system bell from Javascript?
Chrome OSX
I found the following answer, but it does not seem to work in an HTML page:
console.log('\u0007');
How I trigger the "System Bell" in nodejs
Is there a way to ring the system bell from Javascript?
Chrome OSX
Share Improve this question edited May 23, 2017 at 12:07 CommunityBot 11 silver badge asked Feb 10, 2013 at 21:41 B SevenB Seven 46k73 gold badges256 silver badges400 bronze badges 1- This answer has a function to make a simple javascript beep() – Hellonearthis Commented Jan 11, 2017 at 8:03
2 Answers
Reset to default 5The answer you linked to works for Node because Node's console.log
writes to the standard output of the process. It's actually the system's terminal emulator that sees the BEL
character and makes a beep. (No different than if you put a BEL
in a file and ran cat
on that file.)
Since browser script does not have access to standard output, you're out of luck.
However, you could use the <audio>
tag to play a sound of your choice.
You can't. Imagine how annoying that would be... I could do this, for example:
console.log(new Array(100000).join('\x07'));
And you'd get 99999 beeps.
本文标签: Is it possible to ring the system bell with JavascriptStack Overflow
版权声明:本文标题:Is it possible to ring the system bell with Javascript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741862201a2401691.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论