How to Auto-popup a Lightbox Form

October 15, 2021

Automatically Open a Lightbox Form After the Page Is Loaded

To auto-popup a lightbox form after the page is loaded, just insert openOnLoad:true parameter in the lightbox code.


<script src=""type="text/javascript">
    var JFL_63431346590960 =new JotformFeedback({
        windowTitle:'YOUR FORM TITLE',

Please be careful when adding the said parameter, you should append comma “,” (without quote) after width parameter. Just do exactly the same as shown above.

Automatically Open a Lightbox Form at the Desired Time

You can delay a lightbox form to appear after the page is loaded.

  1. Get your lightbox embed code.
  2. Insert anid attribute after the anchor tag found on the lightbox embed code.

Example, id=”lightboxdelay”, check this sample code:

<aid="lightboxdelay"class="lightbox-21357249698871"style="cursor:pointer;color:blue;text-decoration:underline;display:none;">Cool Contact Form</a>

You can also add display:none; property under style attribute to hide the anchor link, as shown on the above example. 

3. After that, add this script below the lightbox embed code.

<script type="text/javascript">
    var delayseconds =5;
    function pause(){
        myTimer = setTimeout('whatToDo()', delayseconds *1000);
    function whatToDo(){
    window.onload = pause;

  • 5 – means 5 seconds before the lightbox form to auto-popup. You can change 5 to your preference.
  •  lightboxdelay  – is the id attribute value that we’ve added to the lightbox embed code on step 2. Make sure the id value matched in your code if you’re using a different one.

Check out the 5 seconds delay demo here.

Automatically Close a Lightbox Form at the Desired Time

  1. Get your lightbox embed code.
  2. Insert this script below the lightbox embed code.  
  1. <script type="text/javascript">
        var delayseconds =5;
        window.onload = closeLightbox();
        function closeLightbox() {
            }, delayseconds*1000);

3. You can change the delay time from delayseconds variable. 5 means the lightbox will close after 5 seconds.

Important Note: window.onload methods can conflict with each other when called more than one time on a web page. In this case you can use prototype or jQuery methods instead of window.onload method.

Related articles:

Was this guide helpful?
Contact Support:

Our customer support team is available 24/7 and our average response time is between one to two hours.
Our team can be contacted via:

Support Forum:

Contact Jotform Support:

Send Comment:

Jotform Avatar
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.