Title: Can&#8217;t get Javascript API to work
Last modified: March 19, 2019

---

# Can’t get Javascript API to work

 *  Resolved [jheartney](https://wordpress.org/support/users/jheartney/)
 * (@jheartney)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/cant-get-javascript-api-to-work/)
 * Like many users here, I’m trying to set up an automatic popup. Using the “Scripts
   n Styles” plugin, I’m dropping Javascript code into the header of the page I 
   want the popup to appear on. Here’s my Javascript:
 * function myFunction() {
    alert(“myFunction has fired”); DiviPopup.openPopup(‘
   myPopup’); } setTimeout(myFunction, 3000);
 * I get the “myFunction has fired” alert (so I know the the Javascript is executing),
   but no popup.
 * There’s a button on the page labeled “Show popup” which successfully shows the
   popup, so I know the Popups for Divi plugin is working (so tantalizing! if only
   I could get it to work off javascript). Any idea how to get the API call to work?
   I’ve tried using window.openPopup(‘myPopup’); but that doesn’t do anything either.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fcant-get-javascript-api-to-work%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  [Alejandro Flamerich](https://wordpress.org/support/users/aflamerich/)
 * (@aflamerich)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/cant-get-javascript-api-to-work/#post-11328703)
 * Hi jheartney.
 * Same issue like me.
    Use the jquery sintaxis and it will work. I mean (‘#yourid’).
   Regards.
 * Alejandro
 *  Plugin Contributor [Philipp Stracker](https://wordpress.org/support/users/strackerphil-1/)
 * (@strackerphil-1)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/cant-get-javascript-api-to-work/#post-11336621)
 * [@aflamerich](https://wordpress.org/support/users/aflamerich/) Thanks for the
   great input. In fact, you are right: The Popup ID is a CSS selector, which starts
   with a “#” (to match the id=”myPopup” attribute)
 * However, I also found a different bug in the function – the plugin did transform
   all popup IDs to lowercase, so thee request `DiviPopup.openPopup("#myPopup")`
   still does not have any effect.
 * This issue is addressed in version 1.3.0, which I’m preparing at the moment.
 * Philipp 🙂
 *  [Alejandro Flamerich](https://wordpress.org/support/users/aflamerich/)
 * (@aflamerich)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/cant-get-javascript-api-to-work/#post-11336686)
 * Hi Philipp.
 * Im using your plugin and the script function call worked fine for me.
    Just for
   your information. Great plugin by the way.
 * Regards.
    Alejandro
 *  Thread Starter [jheartney](https://wordpress.org/support/users/jheartney/)
 * (@jheartney)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/cant-get-javascript-api-to-work/#post-11336882)
 * I added the # sign and switched to all lowercase on the popup ID, and now it 
   is working! Thanks!

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

The topic ‘Can’t get Javascript API to work’ is closed to new replies.

 * ![](https://ps.w.org/popups-for-divi/assets/icon-256x256.jpg?rev=2553226)
 * [Popups for Divi](https://wordpress.org/plugins/popups-for-divi/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/popups-for-divi/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/popups-for-divi/)
 * [Active Topics](https://wordpress.org/support/plugin/popups-for-divi/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/popups-for-divi/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/popups-for-divi/reviews/)

## Tags

 * [api](https://wordpress.org/support/topic-tag/api/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * 4 replies
 * 3 participants
 * Last reply from: [jheartney](https://wordpress.org/support/users/jheartney/)
 * Last activity: [7 years, 2 months ago](https://wordpress.org/support/topic/cant-get-javascript-api-to-work/#post-11336882)
 * Status: resolved