PC Speaker beep via javascript?
Try following way: It may easy for you....
function play_beep() {
var snd = new Audio("http://www.externalharddrive.com/waves/computer/hello.wav");
snd.play();
return false;
}
<input type="submit" value="Play Beep" onclick="return play_beep();" />
It's possible with JavaScript today.
Here's a quick & dirty function I wrote...
var beep = function(duration, type, finishedCallback) {
if (!(window.audioContext || window.webkitAudioContext)) {
throw Error("Your browser does not support Audio Context.");
}
duration = +duration;
// Only 0-4 are valid types.
type = (type % 5) || 0;
if (typeof finishedCallback != "function") {
finishedCallback = function() {};
}
var ctx = new (window.audioContext || window.webkitAudioContext);
var osc = ctx.createOscillator();
osc.type = type;
osc.connect(ctx.destination);
osc.noteOn(0);
setTimeout(function() {
osc.noteOff(0);
finishedCallback();
}, duration);
};
jsFiddle.
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.