Navigation:  Basic Working Procedures > Links, Anchors, Macros, Scripts and HTML >

Inserting script and Winhelp macro links

Print this Topic Previous pageReturn to chapter overviewNext page
Show/Hide Hidden Text

This function inserts a piece of JavaScript code or a Winhelp macro that is executed when the user clicks on the link in your help file. Note that scripts and macros are not supported in all output formats – see the  compatibility list below for details.

See Scripts, HTML and Macros in the Reference section for some more background information on scripts and macros and how they are implemented and handled.

How to insert a script or macro link
1.Select text in your document if you want to use it as the link. You don't have to do this – you can enter a completely new caption in the Insert Hyperlink dialog box if you want.
2.Open the Insert Hyperlink dialog box. There are two ways to do this:
Press Ctrl+L
Select the Link tool in Write > Insert
3.Select the Script Link tab:

4.Select HTML JavaScript or Winhelp Macro and enter your script or macro in the editing field.

See The Hyperlink dialog for full details on the settings in the dialog.

Script implementation

Help & Manual creates script links by inserting the code you type between <a href=" and ">. For example, if you type:

javascript:alert('Hello World!');

The resulting link created in your output will be:

<a href="javascript:alert('Hello World!');">Link text</a>

This is just a simple example of course, you can place as much code in the script as you want. If you are familiar with JavaScript and HTML you can use this knowledge to create quite complex scripts! You just have to remember that everything you write is inserted between <a href=" and ">. See Scripts, HTML and Macros in the Reference section for more details.

Winhelp macro implementation and translation

Macros can be typed and used just as you would use them manually in Winhelp. Note that Winhelp macros only work in Winhelp, except for the four macros that are translated for HTML Help (see below). If you are also generating other formats you need to create alternatives for the other formats using conditional output. See the help included with Microsoft Help Workshop (the Winhelp compiler package) for documentation of the macro functions available in Winhelp.

Macros translated in HTML Help:

The following four standard Winhelp macros are automatically translated to their HTML equivalents when you compile to HTML Help. This can be convenient as the syntax of these Winhelp macros is simpler and easier to enter:

ALink()

KLink()

TCard()

Close()

Note that only keywords are supported as arguments in the ALink and KLink macros when they are used in HTML Help. All other arguments are ignored.
You do not need the ExecFile() Winhelp macro. Use file links instead they produce the same result much more efficiently.
See Scripts, HTML and Macros in the Reference section for full details on how scripts and macros are implemented and handled.
Macro/script link compatibility in output formats

Winhelp:

All Winhelp macros, no scripts. Paths will generally work.

HTML Help:

JavaScript is broadly supported in CHMs. See the MS HTML Help Workshop documentation for details. Four standard Winhelp macros (see above) are translated to their HTML Help equivalents. Do not use paths.

Visual Studio Help:

Same as for HTML Help.

Webhelp:

Scripts are supported but support depends to a great extent on the user's browser, so use the same caution as when using scripting in any HTML pages.

eBooks:

Script and macro links are not supported.

Adobe PDF:

Script and macro links are not supported.

Word RTF:

Script and macro links are not supported.

See also:

Scripts, HTML and Macros

Inserting plain HTML code

Using HTML templates

Webhelp (Project Configuration)

 


Page url: http://www.helpandmanual.com/help/index.html?hm_working_links_macros.htm