Lightbox opens every time a new page is loaded from the website?

  • discoverdelicious
    Asked on July 21, 2016 at 7:47 AM
    The Lightbox opens every time a new page is loaded from the website. I've had a look for this problem and it seems to be a common one. However the PHP solution generally offered is a little beyond me. Could you help me out?
  • Charlie
    Replied on July 21, 2016 at 9:56 AM

    I am note sure if I understood your concern correctly.

    If you have enabled the "Open on page load" in the "Publishing" wizard before you copy the embed code, then that will automatically set your form to open whenever the page is loaded.

    Here's a quick step by step on how to find that option:

    1. On the "Publish" wizard, select the "Lightbox" option and click the "Customize" button.

    Lightbox opens every time a new page is loaded from the website? Image 1 Screenshot 30

     

    2. You can see the "Open on Page Load". This option will generate an embed code that will automatically opens the form when the page is loaded.

    Lightbox opens every time a new page is loaded from the website? Image 2 Screenshot 41

     

    To learn more about the Lightbox embed code, you can check the following guides:

    https://www.jotform.com/help/220-How-to-create-a-lightbox-form 

    https://www.jotform.com/help/83-Adding-parameters-in-Lightbox-and-Feedback-forms 

    https://www.jotform.com/help/203-How-to-Auto-popup-a-Lightbox-Form 

    https://www.jotform.com/help/140-Using-cookies-to-auto-open-a-lightbox-form-per-browser-session 

    https://www.jotform.com/help/378-How-to-Automatically-Open-or-Load-Lightbox-Form-Based-on-Cookies-Using-Javascript 

     

    I hope that helps.

  • discoverdelicious
    Replied on July 21, 2016 at 11:06 AM

    No basically I have set a delay for the lightbox to open but it opens after x seconds on every page that a user loads. So if they have clicked off the form because they didn't want to enter their email, or if they have already entered their email, the next page they load the lightbox form pops up again.

    I'd like the lightbox to appear once per session?

    Here is the same question as mine asked previously - I cannot understand the solution to it. https://www.jotform.com/answers/546330-My-Lightbox-Opens-Automatically-on-Every-Visit-to-My-Web-Page-How-Can-I-Get-It-to-Do-so-Only-Once-per-Browser-Session

  • Charlie
    Replied on July 21, 2016 at 12:01 PM

    If you would like to open the lightbox embed code based on cookies, then we actually have 2 guides for that. Here they are:

    Option #1: If you can code in PHP, then this will help: https://www.jotform.com/help/140-Using-cookies-to-auto-open-a-lightbox-form-per-browser-session 

     

    Option #2: If you code in Javascript, then you can use this one instead: https://www.jotform.com/help/378-How-to-Automatically-Open-or-Load-Lightbox-Form-Based-on-Cookies-Using-Javascript 

     

    I personally recommend using option #2, you can just copy the custom script from there and replace it with your own. If you are having problems, you can provide us your Lightbox embed code and I'll place it in the custom script that I have.

    We'll wait for your response.

  • discoverdelicious
    Replied on July 22, 2016 at 8:21 AM

    Ok thanks I've gone through option 2 for a while and seems like I've got it to work. However I am having problems incorporating it with my already customised code. So my code before was adjusted in two ways. Firstly it was adjusted to that the width would be the correct width for a mobile device. Secondly it was adjusted so that there was a delay of 10 seconds or so before the pop up appeared.

    This was my code before:

    https://jsfiddle.net/2d75dprg/

    But now that I'm trying to get the code to only appear once per browser session, your proposed solution requires me to change the openOnLoad value to true which means the delay doesn't work. So here is the code that I incorporated into your option 2 solution which doesn't work because (I think) the openOnLoad problem.

    https://jsfiddle.net/epj1hh5o/

    What can I do? Thanks

  • Charlie
    Replied on July 22, 2016 at 9:40 AM

    I see, I checked your custom script, try changing the "openOnLoad" attribute on your code from true to false. That should make your script work as expected.

    Here's your custom script but I have changed the openOnLoad attribute in the code to false: https://shots.jotform.com/charlie/custom_lightbox_887634.html. See if that works as you expected.

    We'll wait for your response.

  • discoverdelicious
    Replied on July 22, 2016 at 9:54 AM

    Yay I think it works. I think when I changed the openOnLoad before myself I thought it wasn't working because the pop up didn't show but that was because it had the cookie so in fact it was working!!

     

    Thanks for all your help guys.

  • Irshad
    Replied on July 22, 2016 at 11:02 AM

    You are most welcome. If you face any issue, or need further assistance, feel free to revert back.

    Thanks.