Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check webRTC datachannel compatibility using JavaScript in client side?

WebRTC datachannel works only in Firefox nightly. How can I check it in client side?

Code is shown as follows;

if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits); 

 var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number

 if (ffversion>=5)

  document.write("You're using FF 5.x or above")

 else if (ffversion>=4)

  document.write("You're using FF 4.x or above")

 else if (ffversion>=3)

  document.write("You're using FF 3.x or above")

 else if (ffversion>=2)

  document.write("You're using FF 2.x")

 else if (ffversion>=1)

  document.write("You're using FF 1.x")
}

else
 document.write("n/a")
like image 718
usercode Avatar asked Feb 26 '26 11:02

usercode


1 Answers

You can simply test if the browser currently supports the features you're going to use. For example:

if (!window.mozRTCPeerConnection)
    // error, browser doesn't support it

If you're interested, here an interesting article: Hello Chrome, it’s Firefox calling!

You basically can implement the same feature in Chrome just using webkit prefix instead of moz.

like image 133
ZER0 Avatar answered Feb 28 '26 01:02

ZER0



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!