call method using javascript

Hello guys,

Is there a way of calling a xojo method from javascript.

so i have a method - thismethod

and i want to call this method from a button using
self.executejavascript (and then call thismethod).

plz note -
plz don’t ask me why not call a method directly

thanks,

Hi Shadid, instead of type “plz don’t ask me why not call a method directly”, explain us why you can’t, maybe someone can find a better solutions.

Howerer, if it’s a build-in button, you don’t need to use javascript, just call your method from the action events.
If you are using a custom control made with websdk (so the button is an html button), you have to call the method putting:

javascript:Xojo.triggerServerEvent('"+ objectControlID + "','thisMethod',[optionalParameters]);

with a “onclick” on your button inside the control SetupHTML event

hi massimo,
thanks for reply,

well, i have been able to avoid many javascript errors (black box with yellow buttons) by using
javascript to make controls visible and invisible. (what used to happen is x o jo would try to
make a control invisible before the control is initialised (as i understand).

second problem is the selection index of webpopupmenu jumps to the first item if there is
a timer running on the web page. see conversation here
https://forum.xojo.com/11878-web-popupmenu-and-timer-problem/p1#p87830

so i am now trying to create a javascript timer (just experiment to see if i can get around the
problem as described in the link above) and not use the inbuilt timers that are affecting my webpopupmenus.

but if i create my own timers i want to call methods to actually make any good use of them.

hope that makes sense. …