AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de Windows / Funciones varias de WINDEV
  • Use conditions
  • Calling WLanguage code from the JavaScript code
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Runs JavaScript code in the context of the Web page displayed by an HTML Display control.
Warning The "No permitir la ejecución de scripts JavaScript" option must be unchecked in the "General" tab of the HTML Display control description window.
Ejemplo
JSCode is string = [
var now = new Date();
alert('We are on: ' + now);
]
HTM_MyHTMLControl.ExecuteJS(codeJS)
JSCode is string = [
var now = new Date();
now;
]

HTM_MyHTMLControl.ExecuteJS(codeJS, ResultJSExecution)

INTERNAL PROCEDURE ResultJSExecution(bSuccess is boolean, ReturnValue)
	IF NOT bSuccess
		Error(ErrorInfo())
		RETURN
	END
	Info(ReturnValue)
END
Sintaxis
<Result> = <HTML Display control>.ExecuteJS(<JavaScript code> [, <WLanguage procedure>])
<Result>: Boolean
  • True if the JavaScript code was transmitted for execution to the control,
  • False otherwise.
<HTML Display control>: Control name
Name of the HTML Display control on which the JavaScript script will be executed.
<JavaScript code>: Character string
JavaScript code to execute. This code is run in asynchronous mode. The result of the code execution can be retrieved via the <WLanguage procedure> parameter.
The value returned by the JavaScript code corresponds to the value of the expression found in the last line of code. Do not use "return". The expression to be retrieved must be a string.
<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 is string)
This procedure is called once the JavaScript code has been executed. The parameters of this procedure are:
  • <bSuccess>:
    • True if the JavaScript code was successfully executed,
    • False if the execution of JavaScript code generated an error (e.g., error in the JavaScript code). In that case, to get more details on the error, use ErrorInfo.
      AndroidiPhone/iPad Remark:
      • Android A detailed error is returned.
      • iPhone/iPad A generic error is returned.
  • <ReturnValue> contains the value of the last expression of the JavaScript code (returned value).
Observaciones
Android

Use conditions

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

Calling WLanguage code from the JavaScript code

You can call WLanguage code from a JavaScript code executed via <HTML Display control>.ExecuteJS or via the HTML code contained in the HTML Display control. The following operations must be performed:
  1. In the "General" tab of the HTML Display control, check "Permitir llamar a código WLanguage desde el código HTML (función JavaScript WL.Execute)".
  2. In the HTML code of control, use WL.Execute to run a WLanguage procedure. The following syntax must be used:
    WL.Execute(<WLanguage procedure name>, <Parameter 1>) [, ... [, <Parameter N>]]] )
    where:
    • <WLanguage procedure name> corresponds to the name of the procedure to be executed.
    • <Parameter N> corresponds to the different parameters to be passed to the procedure:
      • Number of parameters:
        • WindowsiPhone/iPad between 0 and N.
        • Android between 0 and 10.
      • Type of parameters:
        • WindowsiPhone/iPad The parameters of the WLanguage procedure will be passed according to their type: boolean, string, number, null.
        • Android The parameters of the WLanguage procedure will always be passed as strings.
Example:
  • WLanguage procedure
    PROCEDURE ProcFromJS(t)
    ToastDisplay("Called from JS: " + t)
  • Code of the 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: wd300obj.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

Última modificación: 27/03/2025

Señalar un error o enviar una sugerencia | Ayuda local