Hi I am trying to call a function in a .js file from java.
In my Java code I have
@Override
public native void test()
/*-{
//JAVASCRIPT
$wnd.h8();
}-*/;
Just an Alert inside the method works but I can't call one of my functions. I've tryed $wnd, $doc and nothing.
Say I have a functions.js with this in it:
function h8(){
alert("hi");
}
In my index I have:
<!doctype html>
<html>
<head>
<title>GWT Test</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="styles.css" rel="stylesheet" type="text/css">
<script src="js/functions.js"></script>
</head>
<body>
<div align="center" id="embed-html"></div>
<script type="text/javascript" src="html/html.nocache.js"></script>
</body>
</html>
So there you see I am loading the script file in the html, but I get the 'undefined is not a function' error. Whithout $doc or $wnd I get the Can't find variable h8 error.
This is the console error:
GwtApplication: exception: (TypeError)
line: 112978
column: 10
sourceURL: http://127.0.0.1:9876/html/52574FB8FF8725CA72DFF813B62FEE86.cache.js
__gwt$exception: <skipped>: undefined is not a function (evaluating '$wnd.h8()')
(TypeError)
line: 112978
column: 10
sourceURL: http://127.0.0.1:9876/html/52574FB8FF8725CA72DFF813B62FEE86.cache.js
__gwt$exception: <skipped>: undefined is not a function (evaluating '$wnd.h8()')