2015-06-21 159 views
-3

我的網站有index.htmlvoice.html如何檢查語音識別是否支持瀏覽器

如果有人導航到voice.html,如果瀏覽器不支持語音識別,他們應該重定向到index.html

if (!code to check if voice recognition is not supported by the browser) 
{ 
     redirect to index.html 
} 

我正在使用annyang.js。如果我打開voice.html。從OPERA它應該重定向到index.html。因爲我認爲歌劇不支持語音識別。

+1

你的問題不在於你有一個雙重否定。 – stark

+0

那麼你的問題到底是什麼? – L3viathan

+0

@stark赦免。我沒有得到你 – sky

回答

0

你究竟需要做什麼檢測,取決於你的意思是什麼意思的語音識別。如果你的意思是Chrome的x-webkit-speech,這應該工作:

if (document.createElement('input').webkitSpeech === undefined) { 
    location.href = "index.html"; 
} 
+0

我正在使用annyang.js。如果我從OPERA打開voice.html,它應該重定向到index.html,因爲我認爲opera不支持語音識別 – sky

+1

@sky我認爲在你的問題描述中解釋你正在使用'annyang的語音識別是個好主意。 js'我們不介意讀者,所以我們不知道如果我們不知道您使用的是什麼,或者不會支持什麼......詳細的問題是一個可靠答案的關鍵。 – NewToJS

+0

好的...我已經更新了這個問題 – sky

0

It looks like您可以只運行一個truthy支票annyang

if (!annyang) { 
    location.href = 'index.html'; 
}