是否可以检测到Android强制门户浏览器? [英] Is it possible to detect the Android captive portal browser?

查看:111
本文介绍了是否可以检测到Android强制门户浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个强制门户,从Android 5.0+ Lollipop开始,该门户在Android的强制门户浏览器而不是设备的默认浏览器中启动.

I have a captive portal which, as of Android 5.0+ Lollipop, launches in Android's Captive Portal Browser rather than the device's default browser.

我需要以某种方式检测它们是否在强制门户浏览器中(而不是常规的Web浏览器),如果是,则显示不同的内容.

I need to somehow detect if they are in the captive portal browser (as opposed to a regular web browser) and if so, show different content.

是否可以通过检查用户代理或通过Javascript检测它们是否在强制门户浏览器"窗口中?我已经在我的Android 5.1设备上查看了用户代理,但是看不到有什么可以区分它们的:

Is it possible, by examining the User Agent, or through Javascript, to detect if they are within a Captive Portal Browser window? I have looked at the user agents on my Android 5.1 device, but I can't see anything to differentiate them:

静电门浏览器:

Mozilla/5.0 (Linux; Android 5.1; Elite 5 Build/LMY47D) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Mobile Safari/537.36

常规Google铬:

Mozilla/5.0 (Linux; Android 5.1; Elite 5 Build/LMY47D) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.94 Mobile Safari/537.36

版本号略有不同,但这在Android/Chrome版本之间似乎不一致,并且不是确定浏览器类型的可靠方法.

There is a slight difference in the version numbers but this seems inconsistent across Android/Chrome versions and not a reliable way to determine the browser type.

还有其他方法可以检测到它吗?预先感谢.

Are there other ways to detect it? Thanks in advance.

推荐答案

您可以使用 Modernizr 来检测是否存在Fetch API或本地存储功能,这两种功能都存在于常规Google Chrome和Firefox等中,但在强制门户浏览器中不可用.

You can use Modernizr to detect the existence of the Fetch API or Local Storage features, both of which exist in regular Google Chrome and Firefox, etc but aren't available in the captive portal browser.

这篇关于是否可以检测到Android强制门户浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆