IBM®
Skip to main content
    Country/region select      Terms of use
 
 
   
     Home      Products      Services & solutions      Support & downloads      My account     
 
developerWorks
AIX and UNIX
Information Mgmt
Lotus
New to Lotus
Products
How to buy
Downloads
Live demos
Technical library
Training
Support
Forums & community
Events
Rational
Tivoli
WebSphere
Java™ technology
Linux
Open source
SOA and Web services
Web development
XML
My developerWorks
About dW
Submit content
Feedback



developerWorks  >  Lotus  >  Technical Library
developerWorks



Tips from LDD
Setting font properties with JavaScript

Tip submitted by
Fredrik Malmborg


Level: Intermediate
Works with: Notes/Domino
Updated: 01/02/2003

Related link:
More Tips from LDD


Have you ever had problems displaying rich text content on the Web and maintaining a consistent look and feel? Then explore the possibilities of JavaScript and DOM. With this little script called in the onLoad event of a form, you can set the font and size of all text on a document to your preferred settings, regardless of the settings the author chose when entering the text in Notes. Note that this JavaScript works in Microsoft Internet Explorer browsers only.
  1. Open Domino Designer, and select the form in which you want to add the JavaScript.
  2. In the onLoad event of the form, add the following line of code:

    setFont();
  3. In the JS Header, add the following code:

    function setFont() {
    for ( i = 0; i < document.all.length; i++) {
    document.all[i].style.fontFamily = "Verdana";
    document.all[i].style.fontSize = 11;
    }
    }
  4. Save and close the form.

In the previous code, document.all.length contains the number of tags in the document. You can get a handle to a tag by addressing the index (0, 1, 2, and so on) or the ID. For example,

<HTML>
    <HEAD>
      <TITLE>Example page</TITLE>
    </HEAD>
<BODY>
    <FORM>
      <SPAN id="myTag">My text</SPAN>

document.all[0] is the <HTML> tag, document.all[2] is the <TITLE> tag, and document.all["myTag"] is the <SPAN> tag.


SUBMIT YOUR TIPS!
We encourage you to send us your tips (You can also click the "Would you like to submit a tip?" graphic below.) Your tips can be anything you've discovered about any Lotus product. The most important thing is that your tip be interesting, useful, or handy. And be sure to include complete information about how your tip works. For ideas, take a look at our tip archives. If we publish your tip, we'll send you the IBM Redbooks Lotus Collection on CD.






Would you like to submit a tip?
    About IBM Privacy Contact