我在javascript中为精神发育迟滞的人制作了一个小网页(和应用)。有一些图像可供点击。当他们这样做时,他们会听到说出一些文字的声音。现在我想阻止他们在语音结束讲话之前点击。所以声音不会混淆。我想用Event.stopPropagation()
做到这一点。我该怎么做?还有更好的方法吗?
function klok()
{
responsiveVoice.cancel();
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var pause = 7000;
setTimeout(function(){ responsiveVoice.speak(" het is nu "+h+" uur en "+m+" minuten",'Dutch Female', parameters2); },100);
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MenuView</title>
<script src="https://code.responsivevoice.org/responsivevoice.js"></script>
</head>
<body oncontextmenu="return false;">
<p STYLE="text-align: center;">
<img id="myimage" onmousedown="klok()" src="klok.jpg" width=20% height=auto //>
</p>
<script>
function voiceStartCallback() {
console.log("Voice started");
color = "red";
document.body.style.background = color;
}
function voiceEndCallback() {
console.log("Voice ended");
color = "black";
document.body.style.background = color;
}
function voiceEndCallback2() {
console.log("Voice ended");
color = "white";
document.body.style.background = color;
}
var parameters = {
onstart: voiceStartCallback,
onend: voiceEndCallback
}
var parameters2 = {
onstart: voiceStartCallback,
onend: voiceEndCallback2
}
</script>
</body>
</html>