Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to ring the system bell with Javascript?

Tags:

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 from Javascript?

Chrome OSX

like image 842
B Seven Avatar asked Dec 05 '25 17:12

B Seven


2 Answers

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.

like image 81
josh3736 Avatar answered Dec 08 '25 05:12

josh3736


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.

like image 33
Niet the Dark Absol Avatar answered Dec 08 '25 05:12

Niet the Dark Absol



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!