Documentation

All the information you need in one place

How to Open a Popup on Custom JS Function

You can use Nelio Popups to show a popup based on the result of executing a custom JavaScript function of your choice. This can be helpful when displaying different popups depending on the result of a function from your own codebase.

In this article, you’ll learn how to open popups according to a JavaScript function.

Using Custom JS Function Condition

When you are ready to use the Custom JS Function condition, follow these steps:

  1. Go to Nelio Popups » All Popups and edit the one you want.
  2. In the editor sidebar, go to the Settings panel, and open the Conditions tab.
  3. Add or modify a condition by selecting ‘Custom JS function’.
Popup with a Custom JS function condition set.
Popup with a Custom JS function condition set.

Then you need to type the name of your JavaScript function (without parenthesis).

Then, Nelio Popups will try to open the popup according to its configuration (locations and triggers). At that time, Nelio Popups will check if there is a JavaScript function with the name you set in the settings. If the function exists, Nelio Popups will execute it and depending on the result of said execution, the popup will open or not.

Nelio Popups will only open the popup if the result of the execution of your JavaScript function is true. In addition to it, note that the JavaScript function must be accessible in the public scope in order to be executed.

Person writing a new WordPress post on a MacBook

Looking for popups?

We have the best plugin to create popups for WordPress in minutes.

Request Customized Enterprise Pricing

10
200000

With your express consent, we handle the information provided for the purpose of contacting you and until you ask us to delete it.

70% OF YOUR VISITORS DO EXACTLY WHAT
YOU JUST DID AND NEVER COME BACK!

KEEP THEM
ON YOUR SITE
LONGER WITH
NELIO POPUPS

Claim Your Discount Now

Image with a 10%-off coupon

WAIT! BEFORE YOU GO...

Get this awesome discount now!

No, I don't want to save money

Image with a 10%-off coupon

WAIT! BEFORE YOU GO...

Get this awesome discount now!

No, I don't want to save money

YOUR COOKIE SETTINGS


This site uses proprietary operational cookies that have a purely functional purpose and third-party cookies that help us understand how visitors interact with the site by collecting and presenting information anonymously. To get more information about these cookies and the processing of your personal data, check our Privacy & Cookie Policy. Do you accept these cookies and the processing of personal data involved?


If you don’t, you can reject non-operational cookies and continue browsing this site by clicking here.