Title: Running the script with a button
Last modified: May 29, 2024

---

# Running the script with a button

 *  Resolved [phoe999](https://wordpress.org/support/users/phoe999/)
 * (@phoe999)
 * [2 years ago](https://wordpress.org/support/topic/running-the-script-with-a-button/)
 * Hi, I have a problem. I’m using Typeform to create a survey for my website. I
   managed to write a script that, when I press a button, launches a survey in a
   window on my website. I connected the WordPress button ID to the script. At some
   point everything was working, but now suddenly the button instead of running 
   the script redirects to polygonstudio.eu/# (the link in the button settings is
   empty, so it is set to # by default). Below is the script code that I pasted 
   in WPCode to the Head section as “Universal Fragment”:
 *     ```wp-block-code
       <script src="//embed.typeform.com/next/embed.js"></script>
   
       <script>
         document.addEventListener("DOMContentLoaded", function() {
           var myButton = document.getElementById("ankietabutton");
           if (myButton) {
             myButton.addEventListener("click", function() {
               window.typeformEmbed.makePopup('https://9ypjmq3pbhg.typeform.com/to/vz0yqohg#utm_source=tf-embed-popup-button', {
                 mode: 'popup',
                 hideHeaders: true,
                 hideFooter: true
               }).open();
             });
           }
         });
       </script>
       ```
   
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Frunning-the-script-with-a-button%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 1 replies (of 1 total)

 *  Plugin Author [Mircea Sandu](https://wordpress.org/support/users/gripgrip/)
 * (@gripgrip)
 * [2 years ago](https://wordpress.org/support/topic/running-the-script-with-a-button/#post-17789353)
 * Hi [@phoe999](https://wordpress.org/support/users/phoe999/),
 * From what I can see, the Typeform script is no longer making the makePopup method
   available in the typeformEmbed object. You can check the Browser Console for 
   JavaScript errors when the button is clicked.
 * The problem here is strictly related to the script you are trying to add and 
   not specific to WPCode, I suggest checking the Typeform documentation or reaching
   out to their support.

Viewing 1 replies (of 1 total)

The topic ‘Running the script with a button’ is closed to new replies.

 * ![](https://ps.w.org/insert-headers-and-footers/assets/icon-256x256.png?rev=2758516)
 * [WPCode - Insert Headers and Footers + Custom Code Snippets - WordPress Code Manager](https://wordpress.org/plugins/insert-headers-and-footers/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-headers-and-footers/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-headers-and-footers/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-headers-and-footers/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-headers-and-footers/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-headers-and-footers/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Mircea Sandu](https://wordpress.org/support/users/gripgrip/)
 * Last activity: [2 years ago](https://wordpress.org/support/topic/running-the-script-with-a-button/#post-17789353)
 * Status: resolved