Table Of Contents

Integrating a JavaScript File Into a Web Application

Last Modified: March 8, 2019

Connect a JavaScript file to your web application and call functions you defined in a JavaScript Library Interface (JSLI) in your web application.

Before you begin, create and configure a JSLI.

  1. Import the JavaScript file(s) you want to use into your web application.
    1. Save your project.
    2. On the Project Files tab, right-click a web application document or library component document (.gcomp) and select Import files.
    3. Navigate to the JavaScript file(s) you want to add and click Open. Click Copy to close the Copy existing file(s) dialog box.
  2. Integrate the JavaScript file into your web application.
    1. Open the JSLI document associated with the JavaScript file and enter the relative path to the JavaScript file in the HTML script and link dependencies form field. Example:
      <script src="library.js"></script>
      spd-note-note
      Note  

      The JavaScript file must be in the same component as the JSLI document and must be marked as Always include in the component document.

    2. Click Apply Changes.
  3. Add the entry points you defined in the JSLI to any web application in your project.
    1. Open the WebVI in which you want to call the JavaScript function.
    2. On the diagram palette, click Project Items»Software»YourWebAppName. Click the Library folder to show each entry point you defined in that JSLI.
    3. Drop the entry points you want to use on the diagram.
    4. Wire the entry points and complete the diagram.
    5. Run the WebVI. Input data passes from the diagram to the JavaScript code, and output data returns from the JavaScript code to the diagram.

Recently Viewed Topics