A "traditional" approach to JavaScript-ing -- using the "JS Header" form event

A "traditional" approach to JavaScript-ing -- using the "JS Header" form event

and tags on the HTML page. This is good practice because the

tags are loaded into the browser before any other part of the page is loaded, and the browser can interpret all the JavaScript code prior to loading the rest of the page. This technique ensures that the scope of global values and tests for syntax errors are available to all page objects prior to the posting of a page for users to work with.

Since the

tags are created automatically by Domino when it renders a page to the browser, the only way developers could add information to the

tags in R4.x was to include an $$HTMLHead field that held a text value with the JavaScript code. The problem with the $$HTMLHead field is that you need to write a Notes formula to return a text value, and that is usually more difficult than writing the JavaScript code itself!

The R5 Designer has a new form and page event called the JS Header. This event is where developers can insert JavaScript code that will be added between the

tags, thus eliminating the need to use $$HTMLHead fields and pass-thru HTML.

You should use the JS Header form event to do the following:

 

Run code prior to loading a page
Declare JavaScript variables
Declare JavaScript functions that will be called by other JavaScript

    Requires Free Membership to View

    Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.

    By submitting your registration information to SearchDomino.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchDomino.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

events
Declare JavaScript objects that will be used by other JavaScript events

Since the JS Header event loads prior to the rest of the page, setting global variable values can be tricky, especially if the variable value is based on a value rendered in the page. When the page is being loaded into the browser, none of the page objects are available at the time the JS Header is being interpreted. A common practice by Domino developers is to declare global variables in the JS Header event and then set the variables in the onLoad event of the form.


This was first published in May 2000

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.