The standard HTML template in HelpNDoc has undergone significant optimizations for enhanced speed in downloading and navigating. This optimization means that when a user selects a topic from the table of contents, HelpNDoc only refreshes the topic's content instead of reloading the entire page. As a result, certain elements like page-specific JavaScript code may not execute when a page is accessed via the table of contents. To address this, HelpNDoc provides a specific event, app.EVENTS.onTopicChanged, to track changes in topics.
The usage of this event is as follows:

app.EVENTS.onTopicChanged = (sUrl) => { /* Custom code run when a new topic is loaded */ }


There are multiple ways to listen to this event:

  • Add "Custom JavaScript" code to the default HTML template's settings. See: HTML documentation settings 
    This will automatically add the code in all generated documentation page
  • Create a new custom template and enter the code within the template's generated content. See: Working with templates 
    This provides greater flexibility at the price of additional initial complexity