Is it possible to detect the Android captive portal browser?

僤鯓⒐⒋嵵緔 提交于 2019-12-21 16:25:17

问题


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.

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.

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:

CAPTIVE PORTAL BROWSER:

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

REGULAR GOOGLE CHROME:

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

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.


回答1:


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.



来源:https://stackoverflow.com/questions/32950326/is-it-possible-to-detect-the-android-captive-portal-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!