Use action links with # or javascript:void(0)

Sometimes, hyperlinks are used to trigger a particular action rather than opening to a given page or resource (such as opening the widget Open widget to a specific article or category.)

If you've imported content from somewhere else, there is a chance you may have added links with this format (or you may have them there on purpose for specific functionality!).

Standard conventions for these types of hyperlinks are to set the link's URL to be either # or javascript:void(0).

The problem

Our editor will usually try to encode that HTML on-save, so instead of getting javascript:void(0), it gets converted to javascript%3Avoid(0), which breaks the link's underlying action.

Solutions

There are two ways to resolve this issue:

  1. Adjust the link URL to use #instead.
    1. This can typically be used in exactly the same way as javascript:void(0) and won't be stripped out by the editor.
  2. Create a snippet that contains the javascript:void(0) text and use that snippet merge code as the URL for these links.

We recommend using the first approach wherever possible, since it is very simple and you can quickly update the URL directly in the article editor. But if you'd like to try the second:

  1. Go to Library > Snippets.
  2. Select the + Create New Snippet button.
  3. When the create snippet page appears give your snippet a Name, like Javascript Void.
  4. Add a snippet Description.
  5. Next to Snippet Content, select Code Editor from the dropdown:
    Image Caption

  6. Copy the code below and paste it into the Snippet Content editor.
    javascript:void(0)
  7. DO NOT toggle the Snippet Content back to WYSIWYG Editor; keep it in Code Editor.
  8. Your final snippet should look something like this:
    Sample Javascript Void snippet
  9. Once you're done making changes, select Create to finish creating your snippet.

With your snippet created, you can use the full merge code as the URL for any hyperlink that you want to use javascript:void(0) in, like this:

Sample hyperlink using the javascriptVoid snippet. Note that the full snippet merge code is used for the URL.