This is an example:
Please specify "don't work".
Do you see an error? What error? Did you add this code to a form unit?
See test project: http://www.tmssoftware.net/public/jscallproc.zip
Bruno Fierens2018-08-09 12:25:02
If it is in the interface section, you can use:
'<div onclick="pas.unit1.test(''Hello'')"> Click me show message </div> '
The compiler cannot know that some Pascal function is accessed from JavaScript code, hence it can strip this code when optimization is chosen.
Hello,
I know this discussion is quite old, but i just need a complementary piece of information on this specific case :
Is there a way to let the optimization active and tell the optimizer to avoid interfering with a specific function, for example with {$ } compilation instructions around the function implementation ?
Sorry, there is at this moment not a compiler define for this.
Used code should not be optimized away, only unused code.
i resolved this problem like this way :
1- TFEBack = Function (qelt: tjselement) : boolean;
2- e_onclickReturn : TFEBack;
3- qtd := document.getElementById('elt_id') ; // qtd is a tjselement
4- qtd.addEventListener('click', @self.handleevent_a); // click or what you want
5-
function handleevent_a(Event: TJSMouseEvent): Boolean;
begin
qelt := tjselement(event.target) ;
elistClick (qelt);
end;
6-
Function elistClick (qelt: tjselement) : boolean;
begin
showmessage(qelt.innerHTML);
end;