skip to main content

Library Routines : WD2$RUN_JS

WD2$RUN_JS
The WD2$RUN_JS library routine executes JavaScript code. It can be used only in Web Direct 2.0 environment.
The routine sends a html snippet that includes a <script> tag to the browser that will interpret it. Calling this routine to execute JavaScript code is suggested only if you need to include js files in the code, otherwise it is prefereable to call WD2$EXECJS.
Note - if you use this routine to redirect the browser to a file created by the COBOL program (e.g. a PDF printed by the program) and you wish to specify a relative path to the file in your JavaScript, be aware that the relative path for the JavaScript doesn’t always match with the relative path used by the COBOL program. When you run your programs from the IDE the relative paths match between COBOL program and JavaScript. Instead, when you deploy your programs in a servlet container (e.g. Tomcat), JavaScript appends the relative path to the webapp main folder while the COBOL program appends them to the servlet container working directory.
Syntax:
 CALL "WD2$RUN_JS" USING jsCode
Parameters:
CALL "WD2$RUN_JS" USING "<script type=""text/javascript"" src=""/functions.js"">function1()</script>"
Return code:
Examples:
Example - Run some Java Script code (this works only on WD2)
call "wd2$run_js" using
"<script type=""text/javascript"" src=""/functions.js"">function1()</script>"

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left