Using a JavaScript Function to Define an Email Link

How to:

When you looked at your WebFOCUS report, you may have noticed that the EMAIL column contained links. The more adventurous among you tried clicking one of these links and received an unfriendly message.

Show All Fans image example

The creator of this report set up the last column so that clicking it executes a script.

If you open the report (by double-clicking it) and page down almost to the bottom, you will see the following line of code:

TYPE=DATA, COLUMN=N4, JAVASCRIPT=Email_Script(N4), $

This line is looking for a JavaScript function named Email_Script. In this section, you will create this JavaScript function. The function will enable end users to send email to the address they click in this column.


Top of page

x
Procedure: How to Define Email_Script
  1. In the Explorer, right-click FanClub, point to New, and then click Project file.
  2. From the Select type of the new item drop-down menu, select Java Script
  3. Give your JavaScript the name MyScript.

    Create New Project file dialog box

    This command creates a JavaScript library. You will be writing the Email_Script function in this library.

  4. Enter the following code:
    function Email_Script(address)
    {
    location = "mailto:" + address;
    }

    Note: Type this code exactly as shown. JavaScript is case-sensitive.

  5. Close MyScript.
  6. Open Show_Fans_Form.
  7. Tile your screen so you can see both Show_Fans_form and the Explorer. Open the Other folder to display your JavaScripts.
  8. Drag MyScript.JS onto the ShowFan form. You must drop MyScript into an empty area on the form, not on top of a control.
  9. You are prompted to either Embed or Link the Script. Select Embed.

    tree diagram

  10. Deploy and run your application.

WebFOCUS