Hi,
I have an HTMLPane whose HTML text defines a javascript function, like the example below:
I want to call that JS function from my SmartGWT code, as an action for a button click, for example. I know JSNI is the way to go, but I couldn't get it working yet, so I'd like some help on how that can be done.
What I did actually was to create a native method that calls the function as a window object, and call that method on the button click handler
But the code above just works on Firefox, on IE I got an error message saying that this property or method is not supported.
So could any of you please give me some ideas on how to do that? Is the function defined in the HTMLPane visible as a window object, or is there any other way to call that?
Thanks,
Matheus
I have an HTMLPane whose HTML text defines a javascript function, like the example below:
Code:
<HTML> <HEAD> <SCRIPT language='javascript'> function myfunction() { alert('Function called!'); } </SCRIPT> </HEAD> </HTML>
What I did actually was to create a native method that calls the function as a window object, and call that method on the button click handler
Code:
// The HTMLPane argument is not used private native void callMyFunction(HTMLPane p) /*-{ $wnd.alert("Will call myfunction"); $wnd.myfunction(); }-*/; (...) IButton b = new IButton("Call JS function"); b.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { callMyFunction(myHTMLPane); } }); (...)
So could any of you please give me some ideas on how to do that? Is the function defined in the HTMLPane visible as a window object, or is there any other way to call that?
Thanks,
Matheus
Comment