0

Hello all,

I am new to javascript and looking for some help. I have searched around different forums but my skills have not served me well to build a working script.

<script language="JavaScript"> 
var myDate = new Date(); 



/* hour is before noon */
if ( myDate.getHours() < 12 )  
{ 
    audio.play('audio1.mp3')
}
else  /* Hour is from noon to 5pm (actually to 5:59 pm) */
if ( myDate.getHours() >= 12 && myDate.getHours() <= 17 ) 
{ 
   audio.play('audio2.mp3')

</script> 
2
Contributors
1
Reply
8
Views
3 Years
Discussion Span
Last Post by albucurus
0

Hi,
try this:

<script language="JavaScript">
        var myDate = new Date();
        /* hour is before noon */
    if ( myDate.getHours() < 12 )
    {
        var myaudio = new Audio("audio1.mp3");
        myaudio.play();
    }
    else /* Hour is from noon to 5pm (actually to 5:59 pm) */
        if ( myDate.getHours() >= 12 && myDate.getHours() <= 17 )
        {
            var myaudio = new Audio("audio2.mp3");
            myaudio.play();
        }
    </script> 
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.