Inserting Scripts into Topics
If you are an advanced user, you can insert a script using JavaScript, VBScript, or JScript into your topics. You can insert a script directly into a content file (e.g., topic, master page) with the user interface or directly in the markup (which allows you to place the script within the <head> tags). If you insert a script into a topic, it is used just for that topic; if you insert a script into a master page, it is used for all topics associated with that master page.
- Open the content file (e.g., topic, snippet).
- In the XML Editor, place your cursor where you want to insert the script.
- Select Insert > Script. The Insert Script dialog opens.
- From the Language drop-down menu, select text/javascript, text/jscript, or text/vbscript.
-
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.
-
-
Click OK. The script is added to the topic, with the script icon displayed at the spot of the insertion.
-
Click
to save your work.
- Open the content file (e.g., topic, snippet).
- 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.
- Enter the script text into the markup.
- Click
to save your work.
Note: If you enter a script directly into the <head> of a topic (in the markup), it will be overwritten in the output if a master page is applied to the topic. However, an alternative is to add a script file to your project (perhaps by using the external resources or SharePoint integration features