Home | Sign in | English EN

This content has been translated automatically. Click here to view the French version.
  • Use conditions
  • Calling WLanguage code from the Javascript code
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Stored procedures
Runs Javascript code in the context of the Web page displayed by an HTML control.
Caution: The option "Forbid the execution of JavaScript scripts" must be unchecked in the "General" tab of the HTML control description window.
JSCode is string = [
var now = new Date();
alert( 'Today is: ' + now);
JSCode is string = [
var now = new Date();
HTM_MyHTMLControl.ExecuteJS(codeJS, ResultJSExecution)
INTERNAL PROCEDURE ResultJSExecution(bSuccess is boolean, ReturnValue)
IF NOT bSuccess
<Result> = <HTML control>.ExecuteJS(<JavaScript code> [, <WLanguage procedure>])
<Result>: Boolean
  • True if the Javascript code was transmitted for execution to the control,
  • False otherwise.
<HTML control>: Control name
Name of HTML control on which the Javascript script will be run.
<JavaScript code>: Character string (with quotes)
Javascript code to run. This code is run in asynchronous mode. The result of code execution can be retrieved via the <Procedure name> parameter.
The value returned by the Javascript code corresponds to the value of the expression found on the last line of Javascript code.
<WLanguage procedure>: Procedure name
WLanguage procedure ("callback") used to find out the result of code execution. This procedure has the following format:
PROCEDURE <Procedure Name>(bSuccess is boolean, <ReturnValue>)
This procedure is called once the Javascript code has been run. The parameters of this procedure are:
  • <bSuccess>:
    • True if the Javascript code was successfully run,
    • False if the execution of Javascript code triggered an error (error in the Javascript code for example). To find out the error details, use ErrorInfo.
      AndroidiPhone/iPad Remark:
      • Android A detailed error is returned.
      • iPhone/iPad A generic error is returned.
  • <ReturnValue> contains the return value of code execution (if this code returns a value).

Use conditions

This function is available on devices running Android version 4.4 or later (api level 19).
The procedure will not be called if the function is used with an earlier system version.
To find out which version of Android the application is running on, use SysAndroidVersion.

Calling WLanguage code from the Javascript code

You have the ability to call WLanguage code from a Javascript code run by 0 or via the HTML code found in the HTML control. The following operations must be performed:
  1. In the "General" tab of HTML control, check "Allow the WLanguage call from the HTML code (JavaScript WL.Execute function)".
  2. In the HTML code of control, use WL.Execute to run a WLanguage procedure. The following syntax must be used:
    WL.Execute(<Name of WLanguage procedure>, <Parameters>)
    • <Name of WLanguage procedure> corresponds to the name of procedure to run.
    • <Parameters> corresponds to a character string that will be passed to the procedure.
  • WLanguage procedure
    PROCEDURE ProcFromJS(t)
    ToastDisplay("Called from JS: " + t)
  • Code of HTML control:
    s is string = [
    <title> A simple example
    function myFunction()
    <h1> This is an HTML page </h1>
    <p id="demo">A paragraph</p>
    <button type="button" onclick="myFunction()">Try</button>
    HTM_NoName1 = s
Related Examples:
WM HTML Dialog Cross-platform examples (WINDEV Mobile): WM HTML Dialog
[ + ] This example explains how to dialog with an HTML control.
It is using the WLanguage "ExecuteJS" function and the Javascript "WL.Execute" function.
Component : wd260obj.dll
Minimum version required
  • Version 23
This page is also available for…
Click [Add] to post a comment