【问题标题】:GWT History JavaScript Not Working in Internet ExplorerGWT 历史 JavaScript 在 Internet Explorer 中不工作
【发布时间】:2011-09-27 09:27:25
【问题描述】:

我无法让 Google Web Toolkit 的 History 类在 Internet Explorer 中运行,即使它在 Chrome、FF 中运行也是如此。

大约 12 个月前,我使用 GWT 2.0 创建了一个应用程序,但发现它有时会停止工作。我将它剥离回第一类,似乎任何时候我调用 History.addValueChangeHandler,Internet Explorer 都会崩溃。

代码如下:

package com.js.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

import com.google.gwt.user.client.ui.Label;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.History;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Test implements EntryPoint, ValueChangeHandler<String>
{

    /**
     * This is the entry point method.
     */
    public void onModuleLoad() {        
        History.addValueChangeHandler(this);
        History.fireCurrentHistoryState();
    }

    public void onValueChange(ValueChangeEvent<String> event) {
        Label loading = new Label( "Loading..." );
        RootPanel.get().add( loading );    
      }    

}

很难相信这会崩溃,但这是错误:

18:50:52.407 [ERROR] [test] Unable to load module entry point class com.js.client.Test (see associated exception for details)
com.google.gwt.core.client.JavaScriptException: (Error): Access is denied. 
 description: Access is denied. 
 number: -2147024891
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:195)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    at com.google.gwt.user.client.impl.HistoryImplIE6.getTokenElement(HistoryImplIE6.java)
    at com.google.gwt.user.client.impl.HistoryImplIE6.init(HistoryImplIE6.java:80)
    at com.google.gwt.user.client.History.<clinit>(History.java:63)
    at com.js.client.Test.onModuleLoad(Test.java:24)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:369)
    at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
    at java.lang.Thread.run(Unknown Source)

任何帮助将不胜感激。谢谢!

【问题讨论】:

    标签: java javascript gwt


    【解决方案1】:

    这是 IE7 吗?您是否使用 JSP/Servlet 来呈现您的主页?如果是,请确保您的 servlet 使用双引号而不是单引号生成历史 iframe/脚本代码。

    【讨论】:

    • 7 和 8 不起作用,兼容模式也不起作用。 9也不行。今天我将尝试 GWT 2.4 看看这是否会改变任何东西。它可能只是我的项目,我以为我尝试过创建一个新项目,但由于所有 eclipse 设置以及它引用的库,我认为我做错了。我没有使用 servlets 页面是带有双引号的 HTML。我只是用我自己的 CSS 使用了股票标准页面。
    • 可以使用 GWT2.4 和新的 eclpise,它可以在 IE8 中使用,但不能在兼容模式下使用。不知道为什么。
    猜你喜欢
    • 2011-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多