Show warning for specific browser

0

I have a web application that works well on all browsers.

It turns out that I needed to develop a feature that is not responding well in the browser that is already installed on Samsung smartphones. Through my Analytics reports, a good portion of my users use this browser.

I'd like to display a warning soon on page load for all users using this browser, stating that it's best if they use Chrome or Opera, for example.

This has to be done right before loading the page, before they can access this feature that I have recently developed.

Can anyone help me?

Thanks in advance!

    
asked by anonymous 09.08.2016 / 13:59

1 answer

1

You can detect the user with the command: navigator.userAgent.match(REGEX DO NAVEGADOR A CHECAR);

For example,

var isMobile = {
    Android: function() {
        return navigator.userAgent.match(/Android/i);
    },
    BlackBerry: function() {
        return navigator.userAgent.match(/BlackBerry/i);
    },
    iOS: function() {
        return navigator.userAgent.match(/iPhone|iPad|iPod/i);
    },
    Opera: function() {
        return navigator.userAgent.match(/Opera Mini/i);
    },
    Windows: function() {
        return navigator.userAgent.match(/IEMobile/i);
    },
    any: function() {
        return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
    }
};

Then in your onLoad you can call: if( isMobile.Android() ) alert('Android');

In this way, I think you have to see what the "useragent" that Samsung's browser sends and treat it.

There are also some libraries that help with this, but I never got to use it, for example MobileESP project .

Code snippets above have been taken from this site .

    
09.08.2016 / 14:30