Using html / javascript embed for text hyperlink within paragraph or rich text

I feel like this is so straightforward that I must be missing something, but alas…

I have a rich text block with a number of paragraphs in it. Within one paragraph I have text to the effect of: “In order to manage your preferences click here

However, I can’t seem to make the “here” into the sort of link necessary for the target using the rich text toolbar. I need to have the text link call an onclick event like the following:

<a href=# onClick=“(function(){
  var _hsp = window._hsp = window._hsp || [];
  _hsp.push([‘showBanner’]);
})()“>Cookie Preferences</a>

I was able to use this within an embed code block elsewhere on the site, but I can’t seem to drop such a block in the middle of a sentence.

What am I overlooking?
Thanks


Here is my site Read-Only: LINK
(how to share your site Read-Only link)

HTML embed blocks are always wrapped in a DIV, therefore it will always appear on a new line rather than inline ( as in click here ).

You might be able to hack that using inline CSS, however a better way to solve this is to attach your click event handler separately.

Set your here link to a URL of #, and then add a custom attribute like click-action=prefs.

Then, in your page /body code, you’d attach the event handler and code there, e.g. if you were using jQuery;

<script>
$("[click-action=prefs]").click(function() {
  // your code
});
</script>
1 Like