views:

22

answers:

1

I have a div

<div id="aDiv"></div>

When I try

 Window.alert(RootPanel.get("aDiv").toString());

I get the element however, just after the above statement, when I

alert(document.getElementById("aDiv"));

It returns a null.

Can someone explain the discrepancies?

+2  A: 

GWT's javascript code is loaded into iframe, therefore document doesn't point to the actual root document. To access the root page in GWT's native methods, you should use $doc instead of document and $wnd instead of window.

axtavt
Thank You very much.
kunjaan