How to I make my browser beep from JavaScript [like Toolkit.beep() in Java]?

Jayesh Nazre

There is no direct function for beeping in JavaScript. But you can use applets for the same. I have included a button in the applet. When you click it the beep sound will come. If you do not want a button in the applet then just do not include it. Use a input type=button and in its clicked event call the Java function beep() I have written.

The HTML Code :

<script language=javascript>
function test() {



<form name=frm_test id=frm_test>
<input type=button value=BEEPJScript onclick=test()>

<applet code="Beep.class" width=100 height=100

The Java code :

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

public class Beep extends Applet implements ActionListener {
  Button b;

  public void init() {
    b = new Button ("BEEPJava");
    b.addActionListener (this);

  public void actionPerformed (ActionEvent ae) {
    this.beep ();

  public void beep() {
NOTE: If you do not want the applet to be shown in your HTML then do not add the button to the applet and make the width and height in the html code to "0" for the applet tag.