public class WebBrowser extends Object implements Serializable
Constructor and Description |
---|
WebBrowser() |
Modifier and Type | Method and Description |
---|---|
String |
getAddress()
Gets the IP-address of the web browser, if available.
|
String |
getBrowserApplication()
Get the browser user-agent string.
|
int |
getBrowserMajorVersion()
Gets the major version of the browser the user is using.
|
int |
getBrowserMinorVersion()
Gets the minor version of the browser the user is using.
|
Date |
getCurrentDate()
Returns the current date and time of the browser.
|
int |
getDSTSavings()
Returns the offset in milliseconds between the browser's GMT TimeZone and
DST.
|
Locale |
getLocale()
Gets the locale reported by the browser.
|
int |
getRawTimezoneOffset()
Returns the browser-reported TimeZone offset in milliseconds from GMT
ignoring possible daylight saving adjustments that may be in effect in
the browser.
|
int |
getScreenHeight()
Gets the height of the screen in pixels.
|
int |
getScreenWidth()
Gets the width of the screen in pixels.
|
String |
getTimeZoneId()
Returns the TimeZone Id (like "Europe/Helsinki") provided by the browser
(if the browser supports this feature).
|
int |
getTimezoneOffset()
Returns the browser-reported TimeZone offset in milliseconds from GMT.
|
boolean |
isAndroid()
Tests if the browser is run on Android.
|
boolean |
isChrome()
Tests whether the user is using Chrome.
|
boolean |
isChromeOS()
Tests if the browser is run on ChromeOS (e.g.
|
boolean |
isDSTInEffect()
Returns whether daylight saving time (DST) is currently in effect in the
region of the browser or not.
|
boolean |
isEdge()
Tests whether the user is using Edge.
|
boolean |
isEs5AdapterNeeded()
Checks if the browser needs `custom-elements-es5-adapter.js` to be
loaded.
|
boolean |
isEs6Supported()
Checks if the browser supports ECMAScript 6, based on the user agent.
|
boolean |
isFirefox()
Tests whether the user is using Firefox.
|
boolean |
isIE()
Tests whether the user is using Internet Explorer.
|
boolean |
isIOS()
Tests if the browser is run in iOS.
|
boolean |
isIPad()
Tests if the browser is run on IPad.
|
boolean |
isIPhone()
Tests if the browser is run on IPhone.
|
boolean |
isLinux()
Tests whether the user is using Linux.
|
boolean |
isMacOSX()
Tests whether the user is using Mac OS X.
|
boolean |
isOpera()
Tests whether the user is using Opera.
|
boolean |
isSafari()
Tests whether the user is using Safari.
|
boolean |
isSecureConnection()
Checks if the connection was established using HTTPS.
|
boolean |
isTooOldToFunctionProperly()
Checks if the browser is so old that it simply won't work with a Vaadin
application.
|
boolean |
isTouchDevice()
Checks if the browser supports touch events.
|
boolean |
isWindows()
Tests whether the user is using Windows.
|
boolean |
isWindowsPhone()
Tests whether the user is using Windows Phone.
|
void |
updateRequestDetails(VaadinRequest request)
For internal use only.
|
public int getScreenHeight()
public int getScreenWidth()
public String getBrowserApplication()
public String getAddress()
public Locale getLocale()
public boolean isSecureConnection()
public boolean isFirefox()
public boolean isIE()
public boolean isEdge()
public boolean isSafari()
public boolean isOpera()
public boolean isChrome()
public int getBrowserMajorVersion()
Note that Internet Explorer in IE7 compatibility mode might return 8 in some cases even though it should return 7.
public int getBrowserMinorVersion()
getBrowserMajorVersion()
public boolean isLinux()
public boolean isMacOSX()
public boolean isWindows()
public boolean isWindowsPhone()
public boolean isAndroid()
public boolean isIOS()
public boolean isIPhone()
public boolean isIPad()
public boolean isChromeOS()
public int getTimezoneOffset()
getRawTimezoneOffset()
.getRawTimezoneOffset()
public String getTimeZoneId()
public int getRawTimezoneOffset()
You can use this to figure out which TimeZones the user could actually be
in by calling TimeZone.getAvailableIDs(int)
.
If getRawTimezoneOffset()
and getTimezoneOffset()
returns the same value, the browser is either in a zone that does not
currently have daylight saving time, or in a zone that never has daylight
saving time.
public int getDSTSavings()
public boolean isDSTInEffect()
public Date getCurrentDate()
To get the actual date and time shown in the end users computer, you can do something like:
WebBrowser browser = ...; SimpleTimeZone timeZone = new SimpleTimeZone(browser.getTimezoneOffset(), "Fake client time zone"); DateFormat format = DateFormat.getDateTimeInstance(); format.setTimeZone(timeZone); myLabel.setValue(format.format(browser.getCurrentDate()));
isDSTInEffect()
,
getDSTSavings()
,
getTimezoneOffset()
public boolean isTouchDevice()
public void updateRequestDetails(VaadinRequest request)
request
- the Vaadin request to read the information frompublic boolean isTooOldToFunctionProperly()
public boolean isEs6Supported()
true
if the browser supports ES6, false
otherwise.public boolean isEs5AdapterNeeded()
true
if the browser needs the adapter,
false
otherwise.Copyright © 2018. All rights reserved.