Including JavaScript on a Notes form or page
If you've never used JavaScript in a Lotus Notes application before, you can add it to a Notes form or page just as you would a Web page. As long as the JavaScript you add to the form or page is supported by the Notes client, it works just like it does in a browser.
The <script> tag
There are a several different ways to include JavaScript in a Lotus Notes form or page. One way is through the use of the <script> tag. You can place the <script> tag anywhere on the form or page and the JavaScript inside the tag will be executed as the page or form is loaded. In order for the JavaScript to be used this way to properly execute in the Notes client, the following criteria must be met:
- The "Enable JavaScript" option in the Notes Client Configuration must be selected.
- The <script> tag and its contents must be marked as pass-thru HTML.
- The form that contains the <script> tag must have the "Render pass through HTML in Notes" option selected on the form or page Properties box.

The JavaScript code contained in the example above produces a similar result in both Lotus Notes and a Web browser as shown in the following figure.
Event handlers
Another method of including JavaScript in a Lotus Notes form or page is in an event handler. An event occurs in the life of a Notes form or page such as when the page loads or a user clicks an action hotspot. Each event has a handler that allows you to determine what, if anything, happens when these events occur. Several Domino objects have JavaScript event handlers:
- Form
- Subform
- Page
- Field
- Action
- Button
- Action hotspot
If you want to execute the checkAnswer() function when leaving a field on a Web page, you add the event handler to the markup for the field as shown in the following example:
<input type="text" id="ChargeCode" onblur="checkChargeCode();">
The same functionality can be achieved in Domino Designer by selecting the onBlur event of the field in the Objects tab and adding the function to the script area as shown in the following figure.

Coding the onBlur event handler for a field in Domino Designer
JavaScript library
Another method of incorporating JavaScript in a Notes form or page is through the use of a JavaScript library. The Linked Scripts section of the JavaScript primer discusses the benefits and creation of external JavaScript files. In Domino Designer, these files are referred to as JavaScript libraries.
A JavaScript library is created in the Script Libraries area of database in the Design pane of Domino Designer, which is the same area that LotusScript and Java libraries are created and accessed. After you create a JavaScript library that contains the variables and functions that you want to reference in your Notes page or form:
- Open the form and place your cursor in the JS Header event.
- Select Create > Resource > Insert Resource from the menu in Domino Designer.
- In the Insert Resource dialog box, select Javascript Libraries under Resource type.
- Select the JavaScript library that you want to include in the form and click OK.

Selecting the JavaScript library that you want to include in the form in the Insert Resource window