How to call a javascript function?

I want to call a javascript function from my button, menu item or any general HEScript code. How can I do that?

Use the built-in HEScript function named ExecuteHTMLScript.

Just follow these steps:

1) Open your HTML Executable project and go to the Script Manager. Double-click the “UserMain” script to open the script editor.

2) Use the following code, for instance, if you want to call your JS code in the default homepage at startup:

procedure OnStartMainWindow;
begin
 // When the main window is going to be displayed (just before the homepage is shown).
 ExecuteHTMLScript("sayHello('world')","JavaScript"); 
end;    

3) Click Save Script.

4) Be sure to have the correct JavaScript function in the default homepage (or any HTML page). For instance:

 <script type="text/javascript">

 function sayHello(name) {
alert('Hello ' + name + '!');
}

 </script>   

Compile your project and that’s all.

Introduction to Scripting

Using the Script Manager

Script Function Reference


Copyright G.D.G. Software 2019. All rights reserved