Hear the time spoken on your website with this Talking Clock Javascript. The talking clock takes the time from your visitors computer, can be configured as to the interval the time is spoken. IE, every 10 seconds etc.
The talking clock javascript is free to dowload as long as the copyright credits remain intact.
(This script may not work with other javascripts, so you may need to play around with the positioning. I had to place the script on a separate page as it clashed with the javascript menu.)
STEP 1
Download this soundfiles.zip. Unzip the files and place the sound files into the same folder as your webpage.
STEP 2
Copy and paste the code below into your html document straight above the </body> tag. You can edit the speaking interval at the top of the script. Nothing else to alter.
<script>
// Edit speaking interval (seconds) var speakinginterval=10
// Do not edit the code below this line
var thistime= new Date() var hours=thistime.getHours()
var minutes=thistime.getMinutes() var ampm speakinginterval=1000*speakinginterval
if (hours<12) { ampm="am" } else if (hours>=12) { ampm="pm"
if (hours!=12) { hours=hours-12 } } function speakthetimeis() { document.all.typesound.src="soundfiles/the_time_is.wav"
var timer=setTimeout("speakhours()",1200) } function speakhours() {
document.all.typesound.src="soundfiles/"+hours+".wav" if (minutes<10)
{ var timer=setTimeout("speakzerominutes()",1200) } else { var timer=setTimeout("speakminutes()",1200)
} } function speakzerominutes() { document.all.typesound.src="soundfiles/0.wav"
var timer=setTimeout("speakminutes()",600) } function speakminutes()
{ document.all.typesound.src="soundfiles/"+minutes+".wav"
var timer=setTimeout("speakampm()",1200) } function speakampm() { document.all.typesound.src="soundfiles/"+ampm+".wav"
thistime= new Date() hours=thistime.getHours() minutes=thistime.getMinutes() if
(hours<12) { ampm="am" } else if (hours>=12) { ampm="pm"
if (hours!=12) { hours=hours-12 } } var content="<embed src=\"soundfiles/"+hours+".wav\"
autostart=\"false\" hidden=\"true\">" content+="<embed
src=\"soundfiles/"+minutes+".wav\" autostart=\"false\"
hidden=\"true\">" soundcontainer.innerHTML=content var timer=setTimeout("speakthetimeis()",speakinginterval)
} if (document.all) { document.write("<span id=\"soundcontainer\"
style=\"position:relative;\">") document.write("<embed
src=\"soundfiles/"+hours+".wav\" autostart=\"false\"
hidden=\"true\">") document.write("<embed src=\"soundfiles/"+minutes+".wav\"
autostart=\"false\" hidden=\"true\">") document.write("<embed
src=\"soundfiles/"+ampm+".wav\" autostart=\"false\"
hidden=\"true\">") document.write("</span>")
document.write("<embed src=\"soundfiles/0.wav\" autostart=\"false\"
hidden=\"true\">") document.write("</span>")
window.onload=speakthetimeis } </script> <embed src="soundfiles/the_time_is.wav"
autostart="false" hidden="true"> <bgsound id="typesound"></embed>
That's it. Enjoy!
No comments:
Post a Comment