How to determine which browser the user is using

54 views
Skip to first unread message

mona

unread,
Nov 3, 2006, 12:41:33 AM11/3/06
to Google Web Toolkit
Hi:

How can I determine in my GWT AJAX code which browser the user is
using?

My app is having a timing issue in Firefox so I'd like to display a
message for Firefox users only.

All help is appreciated.

thanks,
Mona

Mat Gessel

unread,
Nov 3, 2006, 1:49:20 AM11/3/06
to Google-We...@googlegroups.com
When GWT first loads, the bootstrap script (XXX.nocache.html) uses the
browser sniffer defined in UserAgent.gwt.xml to declare a "ua"
variable representing the browser platform. It then selects and loads
a .cache.html with the client application. Unfortunately, the client
app completely replaces the bootstrap script, so the "ua" variable is
lost.

A couple of ideas:

a) copy the script from UserAgent.gwt.xml into a JSNI method and do a
string comparison on the return value.

b) create a class with a method that gets the ua (e.g.
BrowserInfo.getUserAgent()) and create an implementation for each
supported browser which returns the appropriate value. I've already
done this for debugging purposes; the classes are attached.

--
Mat Gessel
http://www.asquare.net

BrowserInfo.jar
Reply all
Reply to author
Forward
0 new messages