I am trying to write browser specific code. Is there a GWT API to find out which browser the client is using?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The GWT Developer’s Guide page on Cross-Browser Support gives a JSNI function that returns the UserAgent string.
Note, however, that you probably want to use Deferred Binding to write browser-specific code, instead of detecting the UserAgent.
Edit: Kasturi points out Window.Navigator.getUserAgent(), which is implemented like so:
So yes, this should do what the function mentioned on the Cross-Browser Support page does (except that it doesn’t call toLowerCase() on it), though again you may be better off using deferred binding.