I have a variable in Javascript, which toggles between true
and false
when full-screen mode is switched on and off, respectively. Now I want to access that variable in my GWT
code, and do some actions accordingly. Can anyone tell me how to do it? I couldn't understand it from the Google documentation on JSNI
...
In JavaScript
var mybool = true;
your JSNI method in MyClass class ;
public static native boolean getNativeVariableType(String jsVar)/*-{
return eval('$wnd.' + jsVar);
}-*/;
Finally using in GWT ;
boolean getFormJs = Myclass.getNativeVariableType("mybool");
As @dodoot raised the point you can try this return !!$wnd[jsVar]
to get ridoff eval
function side effects.
As @manolo said if you are using gwtQuery it will be more handy by writing simply $(window).prop("mybool")
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With