1

我用 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>

4

0 回答 0