2

无法检测到浏览器,我想将此显示为警告(这是来自http://mozilla.github.com/webrtc-landing/的诗句)

    <h3 id="gum" style="color: red; display: none;">
    mozGetUserMedia is missing, do you have the latest
    <a href="http://nightly.mozilla.org/">Nightly</a> and set
    <i>media.navigator.enabled</i> to true?
    </h3>
<script>
 if (!navigator.webkitGetUserMedia || !navigator.mozGetUserMedia) {
    document.getElementById("gum").style.display = "block";}
</script>

这在如何在客户端使用 JavaScript 检查 webRTC 数据通道兼容性?但不支持 navigator.webkit 和 moz ,我该怎么做?

4

1 回答 1

1
if( !( navigator.getUserMedia || navigator.webkitGetUserMedia ||
    navigator.mozGetUserMedia || navigator.msGetUserMedia ) ) {
    // getUserMedia is not supported
}

改编自Capturing Audio & Video in HTML5

或者

navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia ||
        navigator.mozGetUserMedia || navigator.msGetUserMedia;

if ( !navigator.getUserMedia ) {
    // getUserMedia is not supported
} 

重新评论:

var browser = BrowserDetect.browser,
    version = parseInt( BrowserDetect.version, 10 );

if ( !( browser == 'Chrome' && version > 25 ||
     browser == "Firefox" && version > 18 ) ) {
     // do stuff
}     

特征检测优于浏览器嗅探。

于 2013-03-03T00:06:12.613 回答