Showing information about browsers
It could happen that we need browser information in our application. Knowing more about the user can help us with making applications more user-friendly. For example, we could exclude some components in case the browser window is too small or we could display different content to Mac users.
Let's have a look at how to list all the available information about a client web browser.
How to do it...
Carry out the following steps:
First, we get the current page and call the
getBrowserWindowHeight
andgetBrowserWindowWidth
methods. As the names of the methods suggest, these two methods return the browser width and height.Page page = Page.getCurrent(); int browserWindowHeight = page.getBrowserWindowHeight(); int browserWindowWidth = page.getBrowserWindowWidth();
Then, we get the instance of the web browser. The
WebBrowser
class represents the client's browser and there are many interesting getters there. Let's go through a few of them one by one.WebBrowser webBrowser...