IBM®
Skip to main content
    Country/region [select]      Terms of use
 
 
    
     Home      Products      Services & solutions      Support & downloads      My account     
 
developerworks > Dashboard > IBM Lotus Domino Web Application Development > ... > JavaScript primer > Working with JavaScript in Domino Designer
developerWorks
Log In   View a printable version of the current page.
Overview Spaces Forums Blogs Podcasts Wikis Exchange
Working with JavaScript in Domino Designer
Added by jnoltensmeyer, last edited by jservais on Mar 31, 2008  (view change)
Labels: 
(None)

 This is a community wiki. Be sure you are logged in to edit, comment, and add pages. Not a member yet? It's free and simple. Click Login in the upper right corner and Register.
View a PDF of the original wiki content produced in March 2008 by Lotus and IBM Redbooks.
Table of contents | Previous | Next

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.

<script> tag in Domino Designer

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.

<script> example in Lotus Notes <script> example in web browser

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 an event handler in Domino Designer
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:

  1. Open the form and place your cursor in the JS Header event.
  2. Select Create > Resource > Insert Resource from the menu in Domino Designer.
  3. In the Insert Resource dialog box, select Javascript Libraries under Resource type.
  4. Select the JavaScript library that you want to include in the form and click OK.

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


    About IBM Privacy Contact