Title: javascript code in settings?
Last modified: April 11, 2021

---

# javascript code in settings?

 *  Resolved [caleb1](https://wordpress.org/support/users/caleb1/)
 * (@caleb1)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/javascript-code-in-settings/)
 * I am trying to make a link within the woocommerce checkout privacy policy text
   that opens a popup window.
    Specifically the following code: `<a href="http://
   straightawayfarms.com/policies.html" target="popup" rel="noopener">`
 * But when I do that and click save, it seems to remove the entire “onclick=….”
   from the link and becomes this:
    `<a href="http://straightawayfarms.com/policies.
   html" target="popup" rel="noopener">`
 * Almost like it does not allow use of javascript within those settings fields?
 * Does anyone know how else I could get a link in that privacy policy text to open
   as a popup window?
    Thanks.
    -  This topic was modified 4 years, 12 months ago by [caleb1](https://wordpress.org/support/users/caleb1/).
      Reason: fix the formatting so that the code read as text not applied to the
      message
    -  This topic was modified 4 years, 12 months ago by [caleb1](https://wordpress.org/support/users/caleb1/).

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [Stef](https://wordpress.org/support/users/serafinnyc/)
 * (@serafinnyc)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/javascript-code-in-settings/#post-14305339)
 * It’s not allowed. Just add an ID or class selector and write your JS in your 
   child theme.
 * You could also copy over the template file over to your child theme and write
   it there, but I wouldn’t suggest it.
 *  Thread Starter [caleb1](https://wordpress.org/support/users/caleb1/)
 * (@caleb1)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/javascript-code-in-settings/#post-14309288)
 * Thanks for the reply [@serafinnyc](https://wordpress.org/support/users/serafinnyc/).
   
   I am not an expert with code and programming, especially js.
 * Do you know where I could find the exact code to use and where to insert it to
   do what you are suggesting? I tried googling, but I could not find anything specific….
 * Really appreciate your help.
 *  [Stef](https://wordpress.org/support/users/serafinnyc/)
 * (@serafinnyc)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/javascript-code-in-settings/#post-14310102)
 * Create a child theme and inside the child theme create a folder called JS and
   then create a file called custom.js
 * Enqeue that file either in your child’s function file or in a custom theme functions.
 * If you’re not into coding then look for a plugin called “Insert Header & Footer”
   and with that you can add JS there.
 *  Thread Starter [caleb1](https://wordpress.org/support/users/caleb1/)
 * (@caleb1)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/javascript-code-in-settings/#post-14319915)
 * Thanks for the response.
    Sorry to keep asking dumb questions, but I add the 
   code to custom header and footer, but how do I tell it to use that code on the
   items with a class? Every time I try to find an answer by googling I can find
   lots of details on how to add js to a page or site but not to a specific item
   with an class. I figured out that I can add a function in script and then call
   it with onclick=”function()”, but the function() is also apparently not allowed
   in the woocommerce settings.
 * Does anyone know how I can tell it to run this code when the item with said class
   is clicked?
 * Thanks again.
 *  [Stef](https://wordpress.org/support/users/serafinnyc/)
 * (@serafinnyc)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/javascript-code-in-settings/#post-14319929)
 * No question is ever dumb. But I will say that this type of question isn’t really
   supported in this forum. Due to the fact that it is custom work.
 * I’m going to forward you to how to trigger a modal/popup. Click [here](https://getbootstrap.com/docs/4.0/components/modal/#examples).
 * Make sure your policy is somewhere either on the page as a html box or in your
   footer of your child’s theme. Or use a plugin that can help create these modals
   for you.
 *  Thread Starter [caleb1](https://wordpress.org/support/users/caleb1/)
 * (@caleb1)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/javascript-code-in-settings/#post-14320026)
 * Thanks for your help. I decided to get a plugin that creates a modal but that
   uses a shortcode and you cant even insert a shortcode in the woocommerce settings.
   
   I think I am spending too much time on such a small detail, I think I will decide
   to live with letting it open in a new tab.
 * Thanks again.
 *  [Stef](https://wordpress.org/support/users/serafinnyc/)
 * (@serafinnyc)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/javascript-code-in-settings/#post-14320198)
 * You’re very welcome 🤗

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘javascript code in settings?’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Stef](https://wordpress.org/support/users/serafinnyc/)
 * Last activity: [4 years, 12 months ago](https://wordpress.org/support/topic/javascript-code-in-settings/#post-14320198)
 * Status: resolved