Package com.vaadin.client
Class BrowserInfo
- java.lang.Object
-
- com.vaadin.client.BrowserInfo
-
public class BrowserInfo extends Object
Class used to query information about web browser. Browser details are detected only once and those are stored in this singleton class.
-
-
Field Summary
Fields Modifier and Type Field Description static StringENGINE_GECKOstatic StringENGINE_PRESTOstatic StringENGINE_TRIDENTstatic StringENGINE_WEBKIT
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static BrowserInfoget()Singleton method to get BrowserInfo object.intgetBrowserMajorVersion()Returns the browser major version e.g., 3 for Firefox 3.5, 4 for Chrome 4, 8 for Internet Explorer 8.intgetBrowserMinorVersion()Returns the browser minor version e.g., 5 for Firefox 3.5.static StringgetBrowserString()StringgetBrowserVersion()Gets the complete browser version in form of a string.StringgetCSSClass()Returns a string representing the browser in use, for use in CSS classnames.floatgetGeckoVersion()Returns the Gecko version if the browser is Gecko based.floatgetIEVersion()intgetMaxTouchPoints()Get maximum supported touch points.floatgetOperaVersion()intgetScreenHeight()intgetScreenWidth()floatgetWebkitVersion()Returns the WebKit version if the browser is WebKit based.booleanisAndroid()Checks if the browser is run on Android.booleanisAndroid23()booleanisAndroidWithBrokenScrollTop()Tests if this is an Android devices with a broken scrollTop implementation.booleanisBrowserVersionNewerOrEqual(int majorVersion, int minorVersion)Checks if the browser version is newer or equal to the given major+minor version.booleanisChrome()booleanisEdge()booleanisFirefox()booleanisGecko()booleanisIE()booleanisIE10()Deprecated.booleanisIE11()booleanisIE8()Deprecated.booleanisIE9()Deprecated.booleanisIOS()Checks if the browser is run on iOS.booleanisIOS6()Checks if the browser is run on iOS 6.booleanisOpera()booleanisOpera10()booleanisOpera11()booleanisSafari()booleanisSafariOrIOS()Returns true if the browser is Safari or is a browser that is running on iOS and using the Safari rendering engine.booleanisTouchDevice()booleanisWebkit()booleanrequiresOverflowAutoFix()Indicates whether the browser might require juggling to properly update sizes inside elements with overflow: auto.booleanrequiresPositionAbsoluteOverflowAutoFix()Indicates whether the browser might require juggling to properly update sizes inside elements with overflow: auto when adjusting absolutely positioned elements.booleanrequiresTouchScrollDelegate()Checks if the browser is capable of handling scrolling natively or if a touch scroll helper is needed for scrolling.
-
-
-
Field Detail
-
ENGINE_GECKO
public static final String ENGINE_GECKO
- See Also:
- Constant Field Values
-
ENGINE_WEBKIT
public static final String ENGINE_WEBKIT
- See Also:
- Constant Field Values
-
ENGINE_PRESTO
public static final String ENGINE_PRESTO
- See Also:
- Constant Field Values
-
ENGINE_TRIDENT
public static final String ENGINE_TRIDENT
- See Also:
- Constant Field Values
-
-
Method Detail
-
get
public static BrowserInfo get()
Singleton method to get BrowserInfo object.- Returns:
- instance of BrowserInfo object
-
getCSSClass
public String getCSSClass()
Returns a string representing the browser in use, for use in CSS classnames. The classnames will be space separated abbreviations, optionally with a version appended. Abbreviations: Firefox: ff Internet Explorer: ie Safari: sa Opera: op Browsers that CSS-wise behave like each other will get the same abbreviation (this usually depends on the rendering engine). This is quite simple at the moment, more heuristics will be added when needed. Examples: Internet Explorer 6: ".v-ie .v-ie6 .v-ie60", Firefox 3.0.4: ".v-ff .v-ff3 .v-ff30", Opera 9.60: ".v-op .v-op9 .v-op960", Opera 10.10: ".v-op .v-op10 .v-op1010"- Returns:
-
isIE
public boolean isIE()
-
isEdge
public boolean isEdge()
-
isFirefox
public boolean isFirefox()
-
isSafari
public boolean isSafari()
-
isSafariOrIOS
public boolean isSafariOrIOS()
Returns true if the browser is Safari or is a browser that is running on iOS and using the Safari rendering engine.- Returns:
- true if the browser is using the Safari rendering engine
- Since:
- 8.1
-
isIE8
@Deprecated public boolean isIE8()
Deprecated.
-
isIE9
@Deprecated public boolean isIE9()
Deprecated.
-
isIE10
@Deprecated public boolean isIE10()
Deprecated.
-
isIE11
public boolean isIE11()
-
isChrome
public boolean isChrome()
-
isGecko
public boolean isGecko()
-
isWebkit
public boolean isWebkit()
-
getGeckoVersion
public float getGeckoVersion()
Returns the Gecko version if the browser is Gecko based. The Gecko version for Firefox 2 is 1.8 and 1.9 for Firefox 3.- Returns:
- The Gecko version or -1 if the browser is not Gecko based
-
getWebkitVersion
public float getWebkitVersion()
Returns the WebKit version if the browser is WebKit based. The WebKit version returned is the major version e.g., 523.- Returns:
- The WebKit version or -1 if the browser is not WebKit based
-
getIEVersion
public float getIEVersion()
-
getOperaVersion
public float getOperaVersion()
-
isOpera
public boolean isOpera()
-
isOpera10
public boolean isOpera10()
-
isOpera11
public boolean isOpera11()
-
getBrowserString
public static String getBrowserString()
-
getScreenWidth
public int getScreenWidth()
-
getScreenHeight
public int getScreenHeight()
-
isTouchDevice
public boolean isTouchDevice()
- Returns:
- true if the browser runs on a touch based device.
-
requiresOverflowAutoFix
public boolean requiresOverflowAutoFix()
Indicates whether the browser might require juggling to properly update sizes inside elements with overflow: auto.- Returns:
trueif the browser requires the workaround, otherwisefalse
-
requiresPositionAbsoluteOverflowAutoFix
public boolean requiresPositionAbsoluteOverflowAutoFix()
Indicates whether the browser might require juggling to properly update sizes inside elements with overflow: auto when adjusting absolutely positioned elements.See https://bugs.webkit.org/show_bug.cgi?id=123958 and http://code.google.com/p/chromium/issues/detail?id=316549
- Returns:
trueif the browser requires the workaround, otherwisefalse- Since:
- 7.1.8
-
getMaxTouchPoints
public int getMaxTouchPoints()
Get maximum supported touch points. For a desktop browser with mouse and keyboard attached, usually returns 0 or 1. For a multi-touch device like a smartphone, returns a value > 1, if supported. On an Apple Mac, returns 1.- Returns:
- a positive integer > 1 if multi-touch is supported, or 0/1 if multi-touch is not supported.
-
isIOS
public boolean isIOS()
Checks if the browser is run on iOS.- Returns:
- true if the browser is run on iOS, false otherwise
-
isIOS6
public boolean isIOS6()
Checks if the browser is run on iOS 6.- Returns:
- true if the browser is run on iOS 6, false otherwise
- Since:
- 7.1.1
-
isAndroid
public boolean isAndroid()
Checks if the browser is run on Android.- Returns:
- true if the browser is run on Android, false otherwise
-
requiresTouchScrollDelegate
public boolean requiresTouchScrollDelegate()
Checks if the browser is capable of handling scrolling natively or if a touch scroll helper is needed for scrolling.- Returns:
- true if browser needs a touch scroll helper, false if the browser can handle scrolling natively
-
isAndroidWithBrokenScrollTop
public boolean isAndroidWithBrokenScrollTop()
Tests if this is an Android devices with a broken scrollTop implementation.- Returns:
- true if scrollTop cannot be trusted on this device, false otherwise
-
isAndroid23
public boolean isAndroid23()
-
getBrowserMajorVersion
public int getBrowserMajorVersion()
Returns the browser major version e.g., 3 for Firefox 3.5, 4 for Chrome 4, 8 for Internet Explorer 8.Note that Internet Explorer 8 and newer will return the document mode so IE8 rendering as IE7 will return 7.
- Returns:
- The major version of the browser.
-
getBrowserMinorVersion
public int getBrowserMinorVersion()
Returns the browser minor version e.g., 5 for Firefox 3.5.- Returns:
- The minor version of the browser, or -1 if not known/parsed.
- See Also:
getBrowserMajorVersion()
-
getBrowserVersion
public String getBrowserVersion()
Gets the complete browser version in form of a string. The version is given by the browser through the user agent string and usually consists of dot-separated numbers. Note that the string may contain characters other than dots and digits.- Returns:
- the complete browser version or
nullif unknown - Since:
- 8.4
-
isBrowserVersionNewerOrEqual
public boolean isBrowserVersionNewerOrEqual(int majorVersion, int minorVersion)Checks if the browser version is newer or equal to the given major+minor version.- Parameters:
majorVersion- The major version to check forminorVersion- The minor version to check for- Returns:
- true if the browser version is newer or equal to the given version
-
-