0
votes

I print User-Agent string of Opera mini on iPad using JavaScript like below.

alert(navigator.userAgent);

Result is

Mozilla/5.0 (iPad; CPU OS 11_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15G77

I don't know how can I detect this browser that is Opera Mini.

enter image description here

1
@HyyanAboFakher I edited Question. - Hyunjin Lee
Please check if it can help: github.com/lancedikson/bowser/issues/158 - NullPointer
Which version of Opera Mini? ... and does it use the old preston engine or the new webkit? - Asons
More importantly, for what do you need to detect if it is Opera? ...also, Opera 16 runs with Webkit engine, hence the different user agent, ...and the most likely reason they changed, is to get by many web servers that will block Opera mini as not being CSS3/HTML5 compliant (Microsoft did a similar trick with Windows phone). ...and all this simply shows why to not spoof user agent but rather detect features. - Asons

1 Answers

1
votes

Why is the User-Agent of Opera mini printed strangely on iPad?

Opera 16 runs with Webkit engine, hence the different user agent.

With Webkit it now support a lot of features the older version (using the Presto engine) didn't.

The reason they changed it, is most like to get by many web servers that will block the older Opera, where they often is spoofing the user agent, and when finding opera mini, block it as being outdated (and note, Microsoft did a similar trick with Windows phone)

...how can I detect this browser that is Opera Mini

Short answer, you can't

Longer answer, there are CSS features like -o-prefocus, media query hacks etc., many of them you can find here: http://browserhacks.com/

The downside with these, when that browser specific property disappears, so will your detection.

Instead, embrace the more future proof way and detect a feature, with e.g. @supports()

At this question there is some more interested reading with how-to using both CSS and script