Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 367
Vahid Avatar asked Feb 27 '26 01:02

Vahid


1 Answers

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';
    }
like image 187
Xavier Maroñas Avatar answered Feb 28 '26 15:02

Xavier Maroñas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!