2012-03-17 77 views
0

在IE瀏覽器中預覽內容時出現以下錯誤。我不明白爲什麼會出現這個錯誤。錯誤的堆棧如下:預覽textarea中的內容

00:37:03.281 [ERROR] Uncaught exception escaped java.lang.AssertionError: Tried to remove unknown handler: com[email protected]54b245 from Event type at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.removeHandler(HandlerManager.java:98) at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.access$7(HandlerManager.java:91) at com.google.gwt.event.shared.HandlerManager.doRemove(HandlerManager.java:273) at com.google.gwt.event.shared.HandlerManager.access$1(HandlerManager.java:271) at com.google.gwt.event.shared.HandlerManager$2.execute(HandlerManager.java:289) at com.google.gwt.event.shared.HandlerManager.handleQueuedAddsAndRemoves(HandlerManager.java:298) at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:183) at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:52) at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116) at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:100) at com.capgent.cpt.client.ImageRollover.onBrowserEvent(ImageRollover.java:250) at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1307) at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1263) at sun.reflect.GeneratedMethodAccessor218.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157) at com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1713) at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165) 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.core.client.impl.Impl.apply(Impl.java) at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:188) at sun.reflect.GeneratedMethodAccessor164.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157) at com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1668) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222) at java.lang.Thread.run(Thread.java:595)

用於預覽內容的代碼如下:

private static native void previewContent() /*-{ 
    top.consoleRef = window.open("","previewTemplate",""); 
    top.consoleRef.document.writeln(
     '<html><head><title>Template Preview</title></head>' 
     +'<body>' 
     + value 
     +'</body></html>' 
    ) 
    top.consoleRef.document.close() 
}-*/; 

哪裏value是內容預覽。

回答

1

不知道這是否是您的錯誤,但您必須在您的JSNI方法中使用$wnd而不是window

GWT JSNI page:

Note that the code did not reference the JavaScript window object directly inside the method. When accessing the browser's window and document objects from JSNI, you must reference them as $wnd and $doc, respectively. Your compiled script runs in a nested frame, and $wnd and $doc are automatically initialized to correctly refer to the host page's window and document.

也看到了這個問題:Which is the difference between $doc.getElementById(「id」) and document.getElementById(「id」) in JSNI