我使用GWT 2.4(我無法將我的版本升級到2.5) 我遇到以下問題:當我使用Chrome,Firefox或Internet Explorer 9或10時,我的系統工作正常非常好;通過使用Internet Explorer 8,我的系統根本不起作用;它顯示了一個空白頁面的用戶,我得到了以下JavaScript錯誤:GWT 2.4 IE8問題
Dettagli errore pagina Web
Agente utente: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0) Timestamp: Thu, 5 Sep 2013 10:56:58 UTC
Messaggio: Argomento non valido. Linea: 28410 Carattere: 54 Codice: 0 URI: http://app.it:8080/myApp/F662F41B287D1686DCB056062754DFEB.cache.html
我正在尋找在網上,我發現這個鏈接:https://code.google.com/p/google-web-toolkit/issues/detail?id=6665 在這個GWT問題,解釋了GWT 2.4有問題與IE8和chromeframe;我做了他們的建議。其實我所做的是:
-
在我的應用程序的HTML頁面
- 添加以下元標記:元HTTP的當量= 「X-UA兼容」 內容=「IE =邊緣,鍍鉻= 1 「
- 我創造了我的自定義PropertyProviderGenerator(見下面的代碼)
- 在我.gwt.xml文件I指定使用個性化的PropertyProviderGenerator(見下面的代碼)
PropertyProviderGenerator
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.linker.ConfigurationProperty;
import com.google.gwt.core.ext.linker.PropertyProviderGenerator;
import java.util.Arrays;
import java.util.List;
import java.util.SortedSet;
public class CustomUserAgentPropertyGenerator implements PropertyProviderGenerator {
private static final List<String> VALID_VALUES = Arrays.asList(new String[]{"ie6", "ie8", "gecko1_8", "safari", "opera", "ie9"});
private static UserAgentPropertyGeneratorPredicate[] predicates =
new UserAgentPropertyGeneratorPredicate[] {
// opera
new UserAgentPropertyGeneratorPredicate("opera")
.getPredicateBlock()
.println("return (ua.indexOf('opera') != -1);")
.returns("'opera'"),
// webkit family (chrome, safari and chromeframe).
new UserAgentPropertyGeneratorPredicate("safari")
.getPredicateBlock()
.println("return (ua.indexOf('webkit') != -1);")
.returns("'safari'"),
// IE9
new UserAgentPropertyGeneratorPredicate("ie9")
.getPredicateBlock()
.println("return (ua.indexOf('msie') != -1 && ($doc.documentMode >= 9));")
.returns("'ie9'"),
// IE8
new UserAgentPropertyGeneratorPredicate("ie8")
.getPredicateBlock()
.println("return (ua.indexOf('msie') != -1 && ($doc.documentMode >= 8));")
.returns("'ie8'"),
// IE6
new UserAgentPropertyGeneratorPredicate("ie6")
.getPredicateBlock()
.println("var result = /msie ([0-9]+)\\.([0-9]+)/.exec(ua);")
.println("if (result && result.length == 3)")
.indent()
.println("return (makeVersion(result) >= 6000);")
.outdent()
.returns("'ie6'"),
// gecko family
new UserAgentPropertyGeneratorPredicate("gecko1_8")
.getPredicateBlock()
.println("return (ua.indexOf('gecko') != -1);")
.returns("'gecko1_8'"),
};
static void writeUserAgentPropertyJavaScript(SourceWriter body, SortedSet<String> possibleValues) {
// write preamble
body.println("var ua = navigator.userAgent.toLowerCase();");
body.println("var makeVersion = function(result) {");
body.indent();
body.println("return (parseInt(result[1]) * 1000) + parseInt(result[2]);");
body.outdent();
body.println("};");
// write only selected user agents
for (int i = 0; i < predicates.length; i++) {
if (possibleValues.contains(predicates[i].getUserAgent())) {
body.println("if ((function() { ");
body.indent();
body.print(predicates[i].toString());
body.outdent();
body.println("})()) return " + predicates[i].getReturnValue() + ";");
}
}
// default return
body.println("return 'unknown';");
}
public String generate(TreeLogger logger, SortedSet<String> possibleValues, String fallback, SortedSet<ConfigurationProperty> configProperties) {
for (String value : possibleValues) {
if (!VALID_VALUES.contains(value)) {
logger.log(TreeLogger.WARN, "Unrecognized "
+ UserAgentGenerator.PROPERTY_USER_AGENT + " property value '"
+ value + "', possibly due to UserAgent.gwt.xml and "
+ UserAgentPropertyGenerator.class.getName()
+ " being out of sync." + " Use <set-configuration-property name=\""
+ UserAgentGenerator.PROPERTY_USER_AGENT_RUNTIME_WARNING
+ "\" value=\"false\"/> to suppress this warning message.");
}
}
assert predicates.length == VALID_VALUES.size();
StringSourceWriter body = new StringSourceWriter();
body.println("{");
body.indent();
writeUserAgentPropertyJavaScript(body, possibleValues);
body.outdent();
body.println("}");
return body.toString();
}
}
MySystem.gwt.xml
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='mysystem'>
<!-- some inherits -->
<property-provider name="user.agent" generator="com.google.gwt.user.rebind.mysystemUserAgentPropertyGenerator"/>
<inherits name="com.google.gwt.user.UserAgent"/>
<set-configuration-property name="user.agent.runtimeWarning" value="false"/>
<!-- the rest of the file -->
<extend-property name="locale" values="en, it" />
</module>
可悲的是通過這樣做我不解決這個問題 任何人都可以建議我任何其他的事情嘗試?
謝謝
安傑洛
您好托馬斯首先感謝您的回覆。可悲的是我嘗試了你的建議,但我總是得到相同的錯誤....我越來越瘋狂...它是從4天我打架:( –