Inserting Scripts

If you are an advanced user, you can insert a script (or a link to a script file) using JavaScript, VBScript, or JScript into your project. You can insert a script or a link directly into a content file (e.g., topic, template page) with the user interface or directly in the markup. If you insert a script into a topic, it is used just for that topic; if you insert a script into a template page, it is used for all topics associated with that template page.

How to Insert a Script With the User Interface

  1. Open the content file.
  2. In the XML Editor, place your cursor where you want to insert the script.
  3. Select Insert > Script. The Insert Script dialog opens.
  4. From the Language drop-down menu, select text/javascript, text/jscript, or text/vbscript.
  5. Do one of the following:

    • In the Script Code area, type the code for the script.

      OR

    • Next to the Script Link field, click the Browse button to find and select a script file (which you would have stored in the Content Explorer).
  6. Click OK. The script is added to the topic, with the script icon displayed at the spot of the insertion.

  7. Click Save the active file. to save your work.

How to Insert a Script Directly in the Markup

  1. Open the content file.
  2. At the bottom of the XML Editor, click the Text Editor tab to see the markup. You can also use split the editor between the XML Editor and the Internal Text Editor. See Internal Text Editor.
  3. Enter the script text—or a link to it—into the markup, usually between the <head> and </head> tags.
  4. Click Save the active file. to save your work.

What’s Noteworthy?

Note If you enter a script directly into the <head> tags of a topic (in the markup), it will be overwritten in the output if a template page is applied to the topic. However, if you add a script file to your project and link to it from the <head> area in the topic markup, the template page will not overwrite the topic script.