What is the correct way to detect Opera using jQuery?

前端 未结 9 1594
梦毁少年i
梦毁少年i 2021-02-19 04:52

Amazon.com recently updated their javascript, and it\'s causing problems with some Opera browsers.

Their browser detection code looks like so, but it\'s faulty:

9条回答
  •  独厮守ぢ
    2021-02-19 05:50

    There is a special window.opera object which is present in all Opera 5+ browsers. So something as simple as:

    if (window.opera && window.opera.buildNumber) { 
        // we are in Opera 
    }
    

    would be enough.

提交回复
热议问题