|
-
Jul 9th, 2004, 09:06 AM
#1
Thread Starter
Junior Member
Play *.wav or beep in javascript
I have a javascript file that runs from an ASP.Net page. I need to either emit a beep or play a wav file of a beep. Can you tell me how to do that? Here is my code where I want to place it.
if (document.getElementById('hidEndAlarm').value == "1")
{
if (document.getElementById('lblTargetTime').innerText == document.getElementById('lblElapsedTime').innerText)
{
// Flash screen and beep
var Flash=0;
// PLAY BEEP HERE
}
}
-
Jul 21st, 2004, 07:53 AM
#2
Frenzied Member
You could make a div which inserts a sound object into the HTML on a certain action... I'm not sure if JavaScript itself has the ability to play sounds
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Jul 22nd, 2004, 02:18 AM
#3
Fanatic Member
this will do it. Let me know if you needit tweaking
Code:
<script type="javascript/text">
var audioOn = false;
function audioDo(doWhat,toWhat){
if(audioOn){
var A = eval('document.'+toWhat);
if (A != null){
if (doWhat=='stop') A.stop();
else{
if (navigator.appName == 'Netscape') A.play();
else{
if (document.M == null){
document.M = false; var m;
for(m in A) if (m == "ActiveMovie"){
document.M = true; break;
}
}
if (document.M) A.SelectionStart = 0;
if (document.M) A.play();
}
}
}
}
}
</script>
then it HTML.
Code:
<a href="#" onclick="audioDo('play','song');">song</a>
<embed NAME="song" SRC="music/song.mp3" ASTERSOUND LOOP="false" AUTOSTART="false" AUTOREWIND="true" HIDDEN="true" WIDTH="0" HEIGHT="0">
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|