简体   繁体   中英

JavaScript: Detect Mobile Embedded Browsers (Captive Portal)

I have a MikroTik HotSpot.

In mobile browsers (Android, iOS, WP), when a user is connecting to HotSpot, the captive portal browser (or embedded browser) pops up.

If we want to disable this embedded browser we have to open (walled garden) some URLs (about 10 or more for all phones) and I don't want to open these URLs for all in my HotSpot.

So, Is there a way to detect these browsers with JavaScript (user-agents maybe) or something?

For iOS devices, I've found this code in php:

if ((strpos($userAgent, 'iphone') || strpos($userAgent, 'ipad')) &&
        (strpos($userAgent, 'mozilla/') !== false) &&
        (strpos($userAgent, 'applewebkit/') !== false) &&
        (strpos($userAgent, 'mobile/') !== false) &&
        (strpos($userAgent, 'safari') === false))
    {
        echo 'CONNECTS FROM CAPTIVE';
    } else {
        echo 'CONNECTS FORM SAFARI';
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM