PC SOFT

AYUDA EN LÍNEA
DE WINDEV, WEBDEV Y WINDEV MOBILE


Este contenido proviene de una traducción automática.. Haga clic aquí para ver la versión original en inglés.
  • Use conditions
  • Calling WLanguage code from the Javascript code
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Otros
Procedimientos almacenados
Runs Javascript code in the context of the Web page displayed by an HTML control.
Caution: The option "Allow the execution of JavaScript scripts" must be checked in the "General" tab of the description window of HTML control. Caution: The option "Forbid the execution of JavaScript scripts" must be unchecked in the "General" tab of the description window of HTML control.
Ejemplo
JSCode is string = [
var now = new Date();
alert( 'Today is: ' + now);
]
HTM_MyHTMLControl.ExecuteJS(codeJS)
JSCode is string = [
var now = new Date();
now;
]

HTM_MyHTMLControl.ExécuteJS(codeJS, ResultJSExecution)

INTERNAL PROCÉDURE ResultJSExecution(bSuccess is boolean, ReturnValue)
IF NOT bSuccess
Error(ErrorInfo())
RETURN
END
Info(ReturnValue)
END
Sintaxis
<Result> = <Control HTML>.Ejecutar JS(<Código Javascript> [, <Procedure name>])
<Result>: Boolean
  • True if the Javascript code was transmitted for execution to the control,
  • False otherwise.
<Control HTML>: Control name
Name of HTML control on which the Javascript script will be run.
<Código Javascript>: 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.
<Procedure name>: Character string (with or without quotes)
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 Note:
      • 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).
Observaciones
Android

Use conditions

This function is available on the 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 the version of Android system on which the application is run, use SysAndroidVersion.

Calling WLanguage code from the Javascript code

You have the ability to call WLanguage code from a Javascript code run by <Control HTML>.ExecuteJS 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>)
    where:
    • <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.
Example:
  • WLanguage procedure
    PROCEDURE ProcFromJS(t)
    ToastDisplay("Called from JS: " + t)
  • Code of HTML control:
    s is string = [
    <html>
    <head>
    <title> A simple example
    </title>
    <script>
    function myFunction()
    {
    WL.Execute("ProcFromJS","titaa");
    }
    </script>
    </head>
    <body>
    <h1> This is an HTML page </h1>
    <p id="demo">A paragraph</p>
    <button type="button" onclick="myFunction()">Try</button>
    </body>
    </html>
    ]
    HTM_NoName1 = s
Componente : wd240obj.dll
Versión mínima requerida
  • Versión 23
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario