我正在制作 Nest 的烟雾和一氧化碳警报 Nest Protect 的模拟器。但是当我按下按钮(点击)时,内环并没有像预期的那样变成蓝色。它会说话,因为我使用了 ResponsiveVoice,但它就是不亮!这是我的(未完成的)代码。
<script src="http://code.responsivevoice.org/responsivevoice.js"></script>
<script>
function delay(millis) {
var date = new Date();
var curDate = null;
do { curDate = new Date(); }
while(curDate-date < millis);
}
function press() {
document.getElementById("unit").src = "assets/img/blue.jpg";
delay(500);
responsiveVoice.speak("Ready. In the Living Room. Press to test.");
delay(500);
document.getElementById("unit").src = "assets/img/idle.jpg";
}
</script>