Detecting what browser you are using?

0 favourites
  • 7 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • How can I detect which browser my app is being used in so that I may enable or disable features based on the result?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Its not that simple. Wish it was.

  • I haven't tried it, but none of Name, Product, UserAgent or Vendor (or a combination) will do the job?

  • Its un reliable apparently, I would like a way to disable audio on stock android phones, I was thinking of using the browser version for this but the general conversation is that this is not such a good test to do.

  • good luck with that, this is normally what the useragent is supposed to report (the browser name and version), but since too many people tried to filter browsers in the past (not having them play audio, or not having them work at all for some really old websites), the result is that every browser tries to look like every other browser to be sure this kind of discrimination based on those infos cannot be done.

    you may be able to find the default user agent string of the android stock browser somewhere though, still seen as a bad idea though.

  • In general, enabling or disabling features depending on the browser is a very bad idea. You want to enable features depending on if the browser supports it, not if they are using a specific browser. For example suppose in 2012 you detected if the user was on Chrome, and only enabled Web Audio effects for that browser. Later Firefox adds support for Web Audio, and soon IE will as well, and you've unnecessarily crippled those browsers because you detected Chrome instead of Web Audio support.

    You can detect the browser based on the user agent string, but all browsers pretend to be all other browsers because developers keep making that exact mistake over and over again. For example IE now pretends to be Chrome so developers who wrote browser tests instead of feature tests get fooled and enable the features which IE also supports. This makes it pretty hard to actually tell which browser it is from the user agent string. It's possible, but then if you do so, you're making exactly the same mistake all over again!

    So don't do it. Think about the problem you are trying to solve and how to make it based on available features rather than the type of browser.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)