سؤال

I would like play a customized alert sound on the browser. It will play from a .wav file I created.

Currently, I am using AngularJS to create an alert by using $window.alert(alert_msg). However, there is no sound with this function. How can I play a customized alert sound on browser when the alert box pops out?

The AngularJS way will be preferred. Otherwise, normal javascript or jquery will be fine too.

Thank you for your help.

هل كانت مفيدة؟

المحلول

you can do it and i do it in my app when certain actions happen:

var mp3 = $('<audio id="soundHandle" style="display:none;"></audio>').attr('src','sound/plop.wav');

$(mp3)[0].play();

so you're creating the object in jquery and then you simply target the object and hit play

نصائح أخرى

You might need to write a custom dialog instead.

See this for example

Bootstrap 3 & AngularJS Dialog/Modals

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top