2012-08-11 96 views
0

可能重複後:
jQuery HTML5 Speech Input如何創建搜索引擎,自動搜索語音識別

我要創建我的網站的搜索引擎將使用語音識別,X-webkit-語音代碼,但事情是我希望一旦用戶說話查詢,它認識到它必須自動搜索當前用戶必須按搜索按鈕或點擊輸入按鈕,我使用以下代碼: -

<form method="get" action="http://www.mysite.com/search/"> <input type="speech" id="speech" name="i" size="50" x-webkit-speech /> <input type="submit" value="Search" /> </form>

你能PLZ告訴我,我需要添加和地方

回答

1

我建議你使用jQuery庫:http://jquery.com/

只需將此代碼添加到您的標題:

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 

加入請添加此行到您的JavaScript文件中:

$(document).ready(function() 
{ 
    $('#speech').bind('webkitspeechchange',function() 
    { 
     $(this).parent('form').submit(); 
    }); 
}); 
+0

thnkx它的工作 – 2012-08-11 13:40:34