Skip to content Skip to sidebar Skip to footer

Is It Possible To Ring The System Bell With Javascript?

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

Solution 1:

The 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.


Solution 2:

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.


Post a Comment for "Is It Possible To Ring The System Bell With Javascript?"