0

Hi all.

I have got a code that detects the most mobile devices except Samsung Galaxy S3 (there may be other exceptions as well). Please advice how is it possible to detect the device Samsung Galaxy S3.

My code is:

<script type="text/javascript">            
    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());
        }
    };
    if(isMobile.any()){
        alert("The device is mobile!");
    }
 </script>

Thank you.

4
Contributors
5
Replies
7
Views
4 Years
Discussion Span
Last Post by eburlea
0
  SAMSUNGALAXY S3: function() {
            return navigator.userAgent.match(/SAMSUNG GALAXY S3/i);
        },
        any: function() {
            return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() 
            || isMobile.Opera() || isMobile.Windows() || ismobile.SAMSUNGALAXY S3());
        }

may you have to edit your code with above code i am not tested it give a try all the best

Edited by AARTI SHRIVAS

0

How are you connected to the Galaxy?
Do you have a cable physically going from the micro-USB plug of the Galaxy to a USB port of a computer?

Don't forget to change the setting within the Galaxy itself. You have to tell it to connect as a media device, not just as a device whose battery needs charging.

0

I need to Specify that when the page is accessed from its default browser, it is not detected, but when accessing the page from Chrome, it is working.

Actually I need to implement a code into a site to re-direct users if they are connected from mobile devices. When we test the script, with most of the phones it is ok, and with Samsung S3 it is ok if accessing the page with Chrome.

0

The code:

alert(navigator.userAgent);

returns 'Mozilla/5.0 (X11;Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.34 Safari/534.24'.

What substring should I take from this string to show that the device is Android?

Edited by eburlea: Spelling.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.