This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

Add an onclick javascript to a SiteOrigin Button widget button

2 years ago · Last reply by Andrew Misplon 2 years ago

I have javascript code that I want to use to open a popup with a button. I’m using the SiteOrigin Button widget. The onclick script works fine in something like this in the Custom HTML widget:
Button
So I know the script is working properly.

Rather than using the Custom HTML widget, I want to use the Button widget so all of the formatting for all buttons on my page and site are the same.

In the Button widget I’m trying to put showPopup() into the onclick field under Other Attributes and SEO. It doesn’t matter what I put into this field, if I save and then reopen the widget, the contents in this field don’t appear. The javascript doesn’t run. Am I using the wrong syntax? Why is this not working?

This is our free support forum. Replies can take several days.

Need fast email support? Get SiteOrigin Premium

Replies

5
  1. rmniemela 2 years, 15 days ago

    hmm… the code for the Custom HTML widget got stripped. Trying again:

    “”Button””

  2. rmniemela 2 years, 15 days ago

    Sigh..

    <button class="button" href="#" onclick="showPopup()">Button</button>
  3. Alex S Staff 2 years, 13 days ago

    Hi,

    Thanks for reaching out. For security reasons, the onclick field maintains an allowlist of popular services that provide onclick support. In the current release, it’s not possible to add to the allowlist but it will be possible in a future update via a hook called siteorigin_widgets_onclick_allowlist_functions. In the meantime, you’ll need to disable the allowlist to use other functions. This poses a security risk so I don’t recommend doing this. Regardless, that can be done using the following PHP:

    add_filter( 'siteorigin_widgets_onclick_allowlist', '__return_false' );

    Kind regards,
    Alex

  4. rmniemela 2 years, 13 days ago

    ok, thanks. I’ll do a workaround.

  5. Andrew Misplon Staff 2 years, 13 days ago

    Thanks for your feedback and understanding.

Replies on this thread are closed.

Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Have a different question or issue?

Start New Thread