Is it possible to make the lightbox auto-popup via a URL?

  • davidvm
    Asked on May 25, 2017 at 3:01 AM

    Hi, is it possible to make the lightbox auto-popup via a URL? I don't want the form to auto-pop for all visitors, but just for some I give a special link, so by clicking on it they will go to my site and have the form auto pop. Is that possible?

  • Nik_C
    Replied on May 25, 2017 at 4:05 AM

    So if you give your customers a link yo your website, when they click the link the form should auto pop-up there?

    If that's the case could the first option here https://www.jotform.com/help/203-How-to-Auto-popup-a-Lightbox-Form work for you:

    Is it possible to make the lightbox auto popup via a URL? Image 1 Screenshot 20

    I'm sorry if I misunderstood the question.

    Please let us know.

    Thank you!

     

  • davidvm
    Replied on May 25, 2017 at 4:23 AM

    Hey Nick,

    Yes, that is correct. But can this be done using the same page with openOnLoad:false, but have it set to 'true' via the URL? Something like site.com/?openonDISABLEDload=true or site.com/?lightbox, so that I don't have to use a second page with openOnLoad:true in the lightbox script.

  • Nik_C
    Replied on May 25, 2017 at 4:40 AM

    I understand what you mean, but that is not possible, unfortunately, the openonDISABLEDload=true is part of script code and that parameter can not be passed to script through URL in that way. 

    Maybe the easiest way would be to clone that whole page allow popup in one of them and disable the pop up in the second one. Then you can share each of the URL as you need.

    But I guess you were already aware of it.

    I couldn't find any easier way to prevent popup.

    Let us know if you need any further assistance.

    Thank you!

     

  • davidvm
    Replied on May 25, 2017 at 4:07 PM

    Thanks Nik, yes, I'm considering using a clone page.

    However, I've found an alternate way: Instead of using your lightbox, I can use the regular embed code and add it to a lightbox of my own, and then I can add a class to it to make it visible depending on the URL, using this script I found:

    <script type="text/javascript">
    switch (window.location.hash) {
       case '#something':
           $('.class1').addClass('class2')
    }
    </script>

    I'm testing it and looks as it could work. I assume I cannot do this with the JotForm lightbox directly because of cross-domain restrictions, right?

    Thanks,

    David.

  • davidvm
    Replied on May 25, 2017 at 4:37 PM

    Maybe this is a more complete script:

    <script type="text/javascript">
       jQuery(function($){
       switch (window.location.hash) {
           case '#something': $('.class-1').addClass('class-2'); break;
       }
    });
    </script>

    It adds a class-2 to any element with class-1 when opening a url like: mysite.com/#something

  • Nik_C
    Replied on May 25, 2017 at 5:30 PM

    Honestly, I'm not sure, I think you should try with regular script embed code since I'm not sure if your code would break the lightbox. 

    Did you test this code, is it working for you?