Opera Mini Browser Detection Using Javascript
-
A Former User last edited by
I have written a javascript code for my website to detect if its running on an Opera Mini browser on mobile devices. Since Opera Mini has a data saving feature, when it is enabled it sometimes doesn't load the site properly, hence I want to display a message by detecting whether the browser used is Opera Mini.
The code posted below works perfectly for Opera Mini on iOS but it doesn't work on Android. Any suggestions to make the code also work for Opera Mini on Android?
<script type="text/javascript"> function o(){ var isMobile = { Opera: function() { return navigator.userAgent.match(/Opera Mini/i); }, }; if( isMobile.Opera() ) alert('If you are using Opera Mini please disable Data Savings Mode to Have a pleasant browsing experience :)'); } window.onload = o; </script>
-
kaniolek last edited by
Hi @conrick
In my case the code below does the trick.
window.onload = function(){ if (navigator.userAgent.indexOf("Opera Mini") !== -1) alert("blah blah"); };
Depending on what geographic areas you target, you may want to reconsider adjusting your site's mobile version to Extreme Data Savings limits, though.
Regards
Kacper