PC Speaker beep via javascript?

jldugger picture jldugger · Oct 28, 2009 · Viewed 15.2k times · Source

I'm revisiting an ID scanner station program we built ages ago and I have a request from users to make a system beep. We're considering moving the system to a web browser, but is it possible to invoke a speaker beep via javascript or something? It doesn't need to be cross-browser compatible, but it probably needs to work on Windows or Linux. The stations in question are not equipped with a soundcard or external speakers, hence the request for a PC speaker access.

I know someone's going to say it, so I'll address this up front: I don't care what you think about applications making noise, this isn't for you. Users request it, it makes sense, and the hardware scanner already makes noise anyways. Yes, we give visual feedback, with distinguishable text and color, but we find that people accept the existing beep as positive feedback and adding more audio context would help.

Answer

LiraNuna picture LiraNuna · Oct 28, 2009

Using JavaScript, it's impossible - JavaScript has no access to the client computer except cookies and the new HTML5 local storage.

What you can do, however, is use a Java applet that will be controllable via JavaScript - hidden or not.

You can find an example here.

This requires Java runtime to be installed on the client computer.