The Insert > Plain HTML Code function allows you to include plain HTML code at any point in your topics and export it unchanged to all HTML-based output formats (HTML Help, Browser-based HTML, eBooks and Visual Studio Help/MS Help 2.0).
Plain HTML code in eBooks:
Note that although plain HTML is exported to eBooks only plain formatting code will actually work in this format. You cannot use scripts or DHTML because the simple viewer application included in eBooks does not interpret any scripting.
When to use plain HTML code:
There are basically two situations where you may want to use plain HTML code:
| • | When you want to add features to your HTML-based output with dynamic HTML and scripting. |
| • | When you want to write your own HTML code to achieve formatting results that you can't create directly with Help & Manual. |
Since the introduction of Help & Manual 4 with its dynamic styles and other radically-improved formatting capabilities you will probably have much less reason to use plain HTML for formatting. However, it is still very useful for advanced users who want to "tweak" their output in any number of ways.
The Insert > Plain HTML Code function is also preferable to using JavaScript links for inserting more complex JavaScript code in your pages. Since the code is inserted in the page you can also include links, and you have more freedom to format your code because you are not restricted by the link insertion syntax.
How plain HTML code is inserted:
Plain HTML code is inserted directly at the current insertion point in your topic text. It is inserted exactly as you write it without any changes, and it is not parsed or syntax-checked in any way. The only exceptions are some graphic file references in your HTML topic templates, which are parsed and exported with your output.
This means that you are 100% responsible for making sure that you write valid code!
Since the entire topic contents are always inserted between the <BODY> and </BODY> tags of the HTML topic template the plain HTML code you enter is also always inserted after the opening <BODY> tag, even if you enter it right at the top of the topic page. It is important to remember this if you are inserting scripts that need to be in the <HEAD> section.
If your code contains scripts that only function if they are in the <HEAD> section or another page section above the <BODY> section it is better to insert the code in the HTML template for topic. See below for details.
Adding HTML code to HTML templates:
You cannot use Insert > Plain HTML Code to add code outside the <BODY> and </BODY> tags of the HTML output pages. If you need to do this you must add the code to the HTML template that is used to generate all the topic code outside the <BODY> and </BODY> tags.
The code you add to the HTML template will be included with every topic generated with the template. If you add the code to the Main template this means the code will be added to almost every topic in your entire project, because Main is the default template.
Adding template code to selected topics only
If you only want to include the code with specific topics just create an additional help window type and add your additional code to the HTML template for that window type. (Each help window type has its own HTML topic template.) Then the code will only be included in topics associated with that help window type.
| • | To assign a help window type to a topic select the name of the help window type in the topic's Topic Options tab, in the Help Window: field. |
Referencing script functions in plain HTML code:
If the code you insert in your topics with Insert > Plain HTML Code contains calls to JavaScript functions you have written you may want or need to include these functions in external .JS files or in the <HEAD> section of your topic pages. There are two ways to do this:
| • | Add your separate .JS script file to the Baggage section to include it in your output. Then edit the HTML template for your topics and add an include for the .JS script file in the appropriate location in the template file. |
| • | Edit the HTML template for your topics and manually add the script with the functions to the <HEAD> section of the template. Note that this will include the script code in every topic page, even those pages where the functions are not needed (see above for details on how to avoid this problem). |
See also:
Inserting script and macro links
Page url: http://www.helpandmanual.com/help/index.html?hm_ref_scriptsmacros_html.htm