just try adding '$' in front of window.test(). i.e. $window.test() and see.
how to call javascript function from SmartGWT function
-
26-06-2022 - |
سؤال
hi all i am trying to call a native Js function called test i wrote in the HTML file in the smartGWT project but it sayes test is not a function
the native java script code in the smartGWT class :
public static native void callTest()/*-{
window.test();
}-*/;
the java script function in the HTMLfile :
<script type="text/javascript">
function test(){
window.alert("test");
}
</script>
and i also added :
<script src="org.example.yourcode.Spiffy.nocache.js"></script>
but as i mantaind it sayes test is not a function
so dos any one have any idea or any one can provide any help please ?
thanx
and when i add $window.test() instead window.test() i get the following message ?
and when i use $wnd.test();
i had the following error :
المحلول
نصائح أخرى
Try using $wnd
instead of window
.
GWT JavaScript is loaded in an iframe in the host page, so "window" and "document" in your JavaScript will refer to the iframe. GWT aliases the host page "window" and "document" via $wnd
and $doc
.
Please read all of this section: http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJSNI.html