【问题标题】:Detecting versions of Opera Mini Extreme Mode with Javascript使用 Javascript 检测 Opera Mini Extreme Mode 的版本
【发布时间】:2016-09-08 09:52:30
【问题描述】:

Opera Mini 中的“Extreme Mode”似乎因设备而异,即使使用相同的 Opera Mini 版本 background-size(例如)在具有 Extreme Mode 的 iPhone 或 Opera Mini Java 模拟器应用程序上也能正常工作,但不适用于具有极限模式的 Android 5。

我查看了官方文档 (https://dev.opera.com/articles/opera-mini-and-javascript/),但没有提供这方面的信息。

我希望能够区分这些明显不同的模式。

现在我正在使用这个脚本来检测 Opera Mini 模式,但isOperaExtreme 对于 iPhone 和 Android 都是如此。我想在背景大小不起作用时使用文本后备。

// start opera detect
// Check if current browser is Opera
var isOpera = window.opera | window.opr | ( navigator.userAgent.indexOf(' OPR/') > -1 ) | ( navigator.userAgent.indexOf(' Coast/') > -1 ) | ( navigator.userAgent.indexOf(' OPiOS/') > -1 );

// Check if the Opera browser is Opera Mini or Opera Mobile in regular mode (called High Savings Mode)
var isOperaHigh = (navigator.userAgent.indexOf('OPR/') > -1) && (navigator.userAgent.indexOf('Mobile') > -1) && (navigator.userAgent.indexOf('Presto/') < 0);

// Check if the Opera browser is Opera Mini in Extreme Savings Mode
  var isOperaExtreme = (navigator.userAgent.indexOf('Opera Mini/') > -1) && (navigator.userAgent.indexOf('Presto/') > -1);
// end opera detect

$('#opera-detection-1').html('isOpera: ' + isOpera);
$('#opera-detection-2').html('isOperaHigh: ' + isOperaHigh);
$('#opera-detection-3').html('isOperaExtreme: ' + isOperaExtreme);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="opera-detection-1">

</div>
<div id="opera-detection-2">

</div>
<div id="opera-detection-3">

</div>

【问题讨论】:

  • 你找到解决办法了吗?
  • 我绕过它,我根本没有检测到浏览器,在我的特殊情况下,我只需要为我的网站中的图像创建兼容性,我使用 SVG,但我还需要回退到适用于旧 Android 浏览器的 PNG。 Opera mini 也不支持 SVG 的背景大小,所以我虽然可以使用检测来解决所有这些问题。我最终没有使用 SVG 作为背景,而只是使用“onerror”切换到 PNG:&lt;img class="top-bar-icon" src="images/svg-images/icn_phone_white.svg" onerror="this.src='images/svg-images/fallback/icn_phone_white.png'; this.onerror=null;" alt=""&gt;
  • 这可能是交换图像的好方法。我会试一试。非常感谢。
  • 还有一个“gulp svg2png”插件可以将 svg 转换为 png,因此您不必手动操作

标签: android opera-mini


【解决方案1】:

使用window.operamini 字段。我是legal

window.operamini 仅在极端模式下可用(完全压缩),因为没有完全压缩 Opera Mini 使用默认浏览器引擎。高储蓄模式只会影响图像、视频等内容。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-06
    • 1970-01-01
    • 2010-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多