Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder crmpicco's Avatar
    Join Date
    Jan 2005
    Location
    Mauchline, Scotland
    Posts
    1,096
    Thanks
    15
    Thanked 1 Time in 1 Post

    detect native/stock Android browser User Agent string via PHP

    I am getting a lot of JavaScript errors on the native/stock Android 4.1 browser only and I would like to detect the User Agent string via PHP.

    I use the Mobile_Detect library to check for OS, devices and browsers, however it does not support detecting the native Android browser.

    There are numerous posts on SO regarding this topic, but not answer it would seem.

    I am getting a lot of errors stating:

    Code:
    Cannot set property 'webkitTransitionDelay'
    Cannot set property 'webkitTransform'
    ...so I would like to switch jQuery Mobile page transitions off for this browser - but I need to have the ability to detect it first.

    Is there a way to detect it? I must stress it's not the OS I want to detect, it's the native browser (also called Android).

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    You can look at using get_browser with an up to date browscap. It's slow as sludge though. If you know the anticipated patterns, you could write your own pattern matches for the user agents.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    Senior Coder crmpicco's Avatar
    Join Date
    Jan 2005
    Location
    Mauchline, Scotland
    Posts
    1,096
    Thanks
    15
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Fou-Lu View Post
    You can look at using get_browser with an up to date browscap. It's slow as sludge though. If you know the anticipated patterns, you could write your own pattern matches for the user agents.
    I have looked into get_browser in the past and read about its many performance issues. I don't think I want to go down that path just for one browser.

    One of the problems I have is that I don't actually know the pattern i'm looking for. I could quite easily do a preg_match on the User Agent string if I knew what the UA string was for the Android Native browser, but I would say that the Android documentation is just as bad as Apple's - non-existant!

    I was hoping there would be a "Android Native" or something similar in the UA, but from what i've found online it seems to be "Android" - which could be the OS or it could be the browser. So not much use there, really.

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Quote Originally Posted by crmpicco View Post
    I was hoping there would be a "Android Native" or something similar in the UA, but from what i've found online it seems to be "Android" - which could be the OS or it could be the browser. So not much use there, really.
    and of course since the user agent in Internet Explorer, Firefox, Chrome and Opera can be set to anything at all it could easily be one of those browsers that identifies itself as "Android Native"
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #5
    Regular Coder
    Join Date
    May 2012
    Location
    USA
    Posts
    102
    Thanks
    0
    Thanked 7 Times in 7 Posts
    Are these javascript errors are coming in all the browsers like IE, Mozilla, Chrome and Safari.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •