How to determine the Opera browser using JavaScript

后端 未结 6 909
清歌不尽
清歌不尽 2020-12-14 17:09

I want to determine that the browser of the client machines in Opera or not using JavaScript, how to do that?

6条回答
  •  庸人自扰
    2020-12-14 17:49

    The above answers no longer work in the new Opera 30. Since Opera now use Chromium. Please use the below:

    var isChromium = window.chrome,
        isOpera = window.navigator.userAgent.indexOf("OPR") > -1 || window.navigator.userAgent.indexOf("Opera") > -1;
    if(isChromium !== null && isOpera == true) {
       // is Opera (chromium)
    } else { 
       // not Opera (chromium) 
    }
    

    The new Opera 30 release now fully uses Chromium and also changed their userAgent to OPR

提交回复
热议问题