Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Browser.version always returns the same for Android 2-4 #2199

Closed
RiZKiT opened this Issue · 4 comments

3 participants

@RiZKiT

There is no way to detect the different Android browser versions. Well, that's a result of the user agent string, but what is a solution?

  1. Fake the browser version and return the Android version instead?
  2. Have something like Browser.Platform.version?
@arian
Owner

It should be possible yes, this is my UA string:

Mozilla/5.0 Linux U Android 2.3.4 en-us SonyEricssonMT15i Build/4.0.2.A.0.42 AppleWebKit/533.1 KHTML, like Gecko Version/4.0 Mobile Safari/533.1

@RiZKiT

Yes, and a friend send me his user agent string from his Galaxy Nexus, both result in Browser.version == 4.

Mozilla/5.0 (Linux; U; Android 4.0.2; de-de; Galaxy Nexus/ICL53F) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30

My problem is, I want to know if i have an Android > 2 browser, because these support position:fixed. For now I check the navigator.userAgent for "Android 2". Maybe i have to deal with it until there is a bulletproof solution to check for position:fixed ... in Modernizr.

@arian
Owner

You should be able to feature test the 'position: fixed', like

function () {
  var container = document.body;
  if (document.createElement &&
      container && container.appendChild && container.removeChild) {
      var el = document.createElement("div");
      if (!el.getBoundingClientRect) {
          return null;
      }
      el.innerHTML = "x";
      el.style.cssText = "position:fixed;top:100px;";
      container.appendChild(el);
      var originalHeight = container.style.height, originalScrollTop = container.scrollTop;
      container.style.height = "3000px";
      container.scrollTop = 500;
      var elementTop = el.getBoundingClientRect().top;
      container.style.height = originalHeight;
      var isSupported = elementTop === 100;
      container.removeChild(el);
      container.scrollTop = originalScrollTop;
      return isSupported;
  }
  return null;
}

source: http://kangax.github.com/cft/

@fakedarren
Collaborator

We've already marked this as wontfix, and I can't condone UA sniffing. So closing.

@fakedarren fakedarren closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.