谷歌语音识别搜索文本问题

时间:2012-05-19 17:32:36

标签: javascript html css

默认文字是输入你的关键字,我点击谷歌语音regonition并说facebook api。然后打开facebook api以及这样的默认文本。输入你的文字facebook api ... google chrome only works

 <form method="GET" name="search" action="index2.php"> 
   <table cellpadding="0px" cellspacing="0px"><tr><td>
   <input type="text" name="q" value="Enter your keywords here" 
 onfocus="if (this.value == 'Enter your keywords here') {this.value = '';}" onblur="if      (this.value == '') {this.value = 'Enter your keywords here';}"
x-webkit-speech style="left:9px;top:4px;position:relative;background-   color:#fafafa;border:1px solid;color:#333;font-size:1.4em;width:400px;height:28px"; />
</td><td><input type="submit" value="Search" name="search" id="searchbutton">
</td></tr></table></form>

1 个答案:

答案 0 :(得分:0)

这是因为webkit语音事件不会触发输入的focus事件。你应该听webkitspeechchange事件。像这样:

onwebkitspeechchange = "this.value = this.value.replace('Enter your keywords here','')";