我有一个扩展AbsolutePanel的Panel,每当我添加具有click处理程序的widget时,它都会抛出JS Exception。这仅在IE 8和9中发生。 代码:
private static class MyCustomPanel extends AbsolutePanel {
private MyCustomPanel (Element elem) {
super(elem);
onAttach();
}
}
然后我使用这个MyCustomPanel在我的DOM应用程序中添加一些Widgets元素
final Panel panel = new MyCustomPanel (element);
panel.add(mywidget);
Where mywidget is different widget which implements ClickListner, ClickHandler and so on.... (In my case I have Scrollable Panel with different Widgets.)
I get my element with this code:
private native static Element getServiceElement(String elementName)
/*-{
debugger;
var element = $wnd.top.document.getElementById("div-"+elementName);
if (element) {
element.innerHTML = '';
}
return element;
}-*/;
This issue hapens only on IE8 and IE9 on FF and Chrome works fine.
JS Exception
Update!
我发现失败的原因是GWT尝试在我的Element上添加EventEistener,因为某些原因它认为我的浏览器是IE6。有没有办法强制我的面板使用attachEvent而不是addEventListener?