Follow

JavaScript Commands: Linking Modules

Interactive modules can be linked sequentially using the OnClose and OnComplete fields. Modules can also be called by links in menus, hyperlinks or pop-ups.

All of the following examples make use of the module URLs or module JavaScript Commands. These can be found in the module settings for selected modules under the Developer section. To access this section, select a module that you have added to your page followed by the Settings palette.

For the first example, it’s important that you are familiar with the purpose of the OnClose and OnComplete fields. Find out more here.


Daisy-chaining modules sequentially

A module can be set up to automatically launch after the current module has been closed or completed. In this example, a Competition module is launched after a pop-up video has finished playing.

  1. Add a Pop-up Video module on the page (this is the only module that the reader will click to activate).
  2. Add a Competition module off-page. This means that the readers cannot trigger the module themselves.
  3. Select the Competition module followed by the Settings palette
  4. Copy the text from the JS Command field. 
  5. Select the Pop-up video module followed by the Settings palette.
  6. Paste the text into the OnComplete Javascript field.
  7. The OnComplete Javascript code will run when the video completes, triggering the Competition module.

Linking to a module from a popup

In this example, a hyperlink within a More Information popup can be clicked to trigger an iFrame pop-up module. As the link is created using a hyperlink, the iFrame's module URL is used. Again, the iFrame module has been placed off-page to prevent the reader from clicking it.

  1. Add a More Information module 
  2. Add an iFrame module off-page, select Settings and copy the text from the Module URL field
  3. Paste into notepad and replace ptiLinkClicked with ptiClosePopupLinkClicked
  4. Edit your More Information popup and insert a hyperlink
  5. Paste the Module URL text into the URL field.
  6. The Module URL code will run when the hyperlink is clicked, triggering the More Information to close and the iFrame to open.

Linking to a module using a menu

In this example, a Javascript command menu item type is used to trigger a module within the publication. Ensure that the menu item type is set to ‘Javascript Command’.

  1. Copy the JS Command from the module you wish to trigger (this module must be in the same publication that the menu is applied to).
  2. Paste it into the field provided.
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.