我想從我的GWT下面 Java調用我的JavaScript的方法是我在做什麼GWT:不能調用JavaScript方法,它是在mymain.html類從我onmoduleload
public void onModuleLoad() {
jsniAlert("test");
}
private static final native void jsniAlert(String test) /*-{
$wnd.alert(test);
$wnd.testJavascript();
}-*/;
HelloJSNI html的
<script type="text/javascript" language="javascript"
src="hellojsni/hellojsni.nocache.js"></script>
<script type="text/javascript">
function testJavascript(var input) {
window.jsniAlert();
var var1inJS = "Default value";
alert("Value of Var1 = " + var1inJS);
var1inJS = input;
alert("Value of Var1 = " + var1inJS);
var var2inJS = "Waht is the value of Var2";
alert("Value of Var2 = " + var2inJS);
}
但是當我運行我的應用程序有一個例外(使用打開我的戰爭文件夾應用程序的主HTML類)
javascriptexception:object doesn't support property or method 'testjavascript'
這是同樣的問題http://stackoverflow.com/questions/10050909/how-can-i-access-some-javascript-file-from-java-in-gwt/ – 2012-04-09 10:58:24