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.
An Example:
<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.
Note: Although I've given the direct answer, I do believe Mark Hurd is offering sound advice regarding not annoying the user.
You may also experience browser compatibility issues with this style of playing sound. PLaying sound from a browser in a cross-browser compatible way is hard!
Isn't it possible to have access to the PC Speaker? (from which we hear BIOS beeps)
@Nirmal, no and FYI modern PC cases don't even have "buzzers" anymore (at least in the 3 last cases I bought).
I get
TypeError: sound.Play is not a function
(in Firefox).