• Resolved nwcasebolt

    (@nwcasebolt)


    I’m trying to put a value in local storage so that the popup will not reopen until the user returns to the site with a new browser instance. Here is the code I’ve put in the box labeled “Opening events: #1 Add the code you want to run before the popup opening.”

    if (window.localStorage.getItem("randomfakeid") == null) {
    return true;
    }

    Here is the code I’ve put in the box labeled “Closing events: #2 Add the code you want to run before the popup closes.”

    window.localStorage.setItem("randomfakeid", true);

    I think this should put a key/value in the user’s browser when the popup closes, check for the value before opening the popup, and prevent the popup from open if the value exists. Nothing has changed, however, and the popup still opens on every page no matter how many times I close it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @nwcasebolt,

    Thank you for contacting us.
    I am sorry for all the inconvenience.
    I have checked the code and everything was correct except one thing.
    Please add this part to your first code:
    else {
    return false;
    }

    or change it completely with this one:
    if (window.localStorage.getItem(“randomfakeid”) != null) {
    return false;
    }

    The above code is made by our developer and is very convenient for your case.
    As the “else” condition is important because the popup always hence, it is returning to true. Therefore if there is no “false” in your code the popup opens.

    Let me know in case you have any questions.

    Hey!

    I was wondering whether you saw our last message.
    Please let us know if there is anything we can help you in a new thread, I will mark this one as resolved.

    Best,
    Popup Builder Team

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom JS is not working for me’ is closed to new replies.