Reputation: 309
Not able to detect browser, I want to show this as warning (this is a verse from 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>
This was discussed in How can I check webRTC datachannel compatibility using JavaScript in client side? but not supporting both navigator.webkit and moz , how should I do it ?
Upvotes: 2
Views: 394
Reputation: 13641
if( !( navigator.getUserMedia || navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia || navigator.msGetUserMedia ) ) {
// getUserMedia is not supported
}
Adapted from Capturing Audio & Video in HTML5.
Or
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia || navigator.msGetUserMedia;
if ( !navigator.getUserMedia ) {
// getUserMedia is not supported
}
Re comment:
var browser = BrowserDetect.browser,
version = parseInt( BrowserDetect.version, 10 );
if ( !( browser == 'Chrome' && version > 25 ||
browser == "Firefox" && version > 18 ) ) {
// do stuff
}
Feature detection is preferable to browser sniffing.
Upvotes: 1