Streaming live at 10am (PST)

Execute javascript script in <a href='javascript:...'>

I need to execute a script when a user clicks on a link.
The script is in the custom code.

When I try using a link <a href='javascript:...'> then the result is that it preprends https:// to ‘javascript:…’

How can I execute a script from a link or with an onClick?

Here is my public share link: LINK
(how to access public share link)

1 Like

Hello @Nathan_Zylbersztejn

If you need to add onCLick to a link because onClick name is reserved, you can use an embed.

Piter :webflow_heart:

Maybe change the href by code.

one button (by id)


  document.getElementById("test").href = "javascript";

More than one button (by custom attribute)

For more than one button. Add custom attribute data-hrefByCode for each button you want to change (Better than classes).


Than loop throw all of this items:

/* get the elements by attribute selector */
var demo = $("[data-hrefByCode='data-hrefByCode']");
/* loop throw */
    $(this).attr('href', `javascript`);


1 Like

Thanks Ezra, but I tried both methods and none of them work

Please Add live url + read only link