Html程序  |  26行  |  862 B

<html>
  <head>
    <title>Speech input with grammar attribute test</title>
    <script type="text/javascript">
      function onspeechresult(value) {
        if (value == "Pictures of the moon") {
          document.getElementById('status').innerHTML = 'PASS';
          document.location = '#pass';
        } else {
          document.location = '#fail';
        }
      }
    </script>
  </head>
  <body style="padding:0; margin:0;">
    <input id='inputField' x-webkit-speech
           x-webkit-grammar="http://example.com/grammar.xml"
           onwebkitspeechchange="onspeechresult(this.value);"
           onchange="onspeechresult(this.value);"
           style="position:absolute; margin:0; padding:0; border:0; width:10px;">
    <br>
    <div id="status">FAIL</div>
    <script>document.getElementById('inputField').focus();</script>
  </body>
</html>