开发者

Using javascript variable from GWT Java

I have defined a javascript variable in head section of html file. E.g var开发者_JAVA技巧 yourName = "Nadeem"; Now I want to utilize this variable in my gwt java file/class/method. But it shows an error: Undefined. Please suggest some hints. Best Wishes.


The trick is to use the right "context" where the variable is defined, i.e. $wnd:

static native String getYourName() /*-{
   return $wnd.yourName;
}-*/;

See http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.html#writing

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜