User Agent for Firefox 3

1334 views
Skip to first unread message

sr

unread,
Aug 19, 2008, 12:52:34 AM8/19/08
to Google Web Toolkit
Hi All,
i set the following properties in my x.gwt.xml file to force
compilation only for firefox 2 and ie6 (only for dev).

<set-property name="user.agent" value="gecko1_8" />
<set-property name="user.agent" value="ie6" />

But this obviously fails for Firefox 3. Does anybody know the
GWT 'user.agent' property value for Firerfox 3 ?

georgopoul...@gmail.com

unread,
Aug 19, 2008, 10:26:41 PM8/19/08
to Google Web Toolkit
The module that defines the user agents is:
com.google.gwt.user.UserAgent

"gecko" should be OK for FF3.

In UserAgent.gwt.xml you will see that code:

<!-- Defines the user.agent property and its provider
function. -->
<!--
-->
<!-- This module is typically inherited via
com.google.gwt.user.User -->
<!--
-->
<module>

<!-- Browser-sensitive code should use the 'user.agent' property -->
<define-property name="user.agent"
values="ie6,gecko,gecko1_8,safari,opera"/>

<property-provider name="user.agent"><![CDATA[
var ua = navigator.userAgent.toLowerCase();
var makeVersion = function(result) {
return (parseInt(result[1]) * 1000) + parseInt(result[2]);
};

if (ua.indexOf("opera") != -1) {
return "opera";
} else if (ua.indexOf("webkit") != -1) {
return "safari";
} else if (ua.indexOf("msie") != -1) {
var result = /msie ([0-9]+)\.([0-9]+)/.exec(ua);
if (result && result.length == 3) {
if (makeVersion(result) >= 6000) {
return "ie6";
}
}
} else if (ua.indexOf("gecko") != -1) {
var result = /rv:([0-9]+)\.([0-9]+)/.exec(ua);
if (result && result.length == 3) {
if (makeVersion(result) >= 1008)
return "gecko1_8";
}
return "gecko";
}
return "unknown";
]]></property-provider>

<!-- Deferred binding to optimize JRE classes based on user agent. --
>
<inherits name="com.google.gwt.emul.EmulationWithUserAgent"/>
</module>

Folke

unread,
Aug 19, 2008, 10:37:49 PM8/19/08
to Google Web Toolkit
gecko1_8 is right for FF3. This fails because you overwrite the
property value "gecke1_8" with "ie6". Set the property only once.
BTW, you can only set _one_ target user agent or all. Something like
"gecko1_8, ie6" does not work.
Reply all
Reply to author
Forward
0 new messages