JotForm User Guide / Advanced Features /

How to Auto-popup a Lightbox Form

How to Auto-popup a Lightbox Form

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({
        formId: 'YOURFORMID',
        base: '',
        windowTitle: 'YOUR FORM TITLE',
        background: '#FFA500',
        fontColor: '#FFFFFF',
        type: 'false',
        height: 500,
        width: 700,
        openOnLoad: true

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 an id attribute after the anchor tag found on the lightbox embed code.

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

    <a id="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.

    <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:

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:
Contact JotForm Support:

Send Comment


  • Thuê xe máy quảng bình


  • Banz

    I want a code to automatically open a popanther window as soon as a visitor enters my site

  • sajilbabu

    plese image path in javascript

  • Investelite Research


  • Sergio

    Thank you!

  • Navneet Singh

    Great work but how can we add some style

  • davidvm

    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?

  • Sophie

    I have a working auto-pop up with delay on my site. Is there any way to disable the auto pop-up after a user's initial sign up?

  • 22ndcenturymedia

    How do you make the exit button bigger and possibly also change color ? Screenshot :

  • DN


    I have no programming skills. I have a Web page. I want to add a contact page which pops up on load of the home page. Need FIRST NAME, LAST NAME, EMAIL, MOBILE. QUESTION 2+1 = TO CONFIRM IT NOT SPAM AND SUBMIT BUTTON.

    Contact data emailed to my email address. Every time someone new fills it. (Hope this is cookie)

    After submitting thankyou message and then homepage displayed.

    People have to fill all details and cannot bypass this page(no close buttons). Background dimmed homepage.

    Your help will be much appreciated.

  • ToToPaPa

    Thanks for this tutorial!

    I have a little problem, I'm trying to autopopup a lightbox with a delay but the windows title is not full sized... It's not aligned with the form.

    var JFL_50513172512342 = new JotformFeedback({
    windowTitle:'As you can see',

    var delayseconds = 1;
    function pause() {
    myTimer = setTimeout('whatToDo()', delayseconds * 1000)
    function whatToDo() {
    window.onload = pause;

    Can you help me?

  • bayviewboom

    ok, wrapping this sample in PRE tags didn't work. Would be nice if jotform provided some means of displaying raw script/html in these support pages, since... that's what we do here....

  • bayviewboom

    ok, here's my script again:

    new JotformFeedback({
    formId : "42252369650152",
    buttonText : "Get updates",
    base : "",
    background : "#F59202",
    fontColor : "#FFFFFF",
    buttonSide : "top",
    buttonAlign : "right",
    type : false,
    width : 450,
    height : 525

  • bayviewboom

    Hi, i want to implement the delay method, but there's no tag in my embed. Here's my script:

    new JotformFeedback({
    formId : "42252369650152",
    buttonText : "Get updates",
    base : "",
    background : "#F59202",
    fontColor : "#FFFFFF",
    buttonSide : "top",
    buttonAlign : "right",
    type : false,
    width : 450,
    height : 525

  • Prafull vyas

    Very nice tutorials but I want to lock whole browser when the lightbox appear please can you tell me how this is possible that lightbox working as js alert.

  • Norby

    How can I activate the lightbox feature on click of button or URL?

  • buddy

    hello, very nice tutorial,

    btw, is it possible to change that form into image or banner?


  • leanneoleary

    This is great but doesn't work on my mobile. Tried in the default browser and in chrome and none Work. Anyone else come across this?

  • bgringer912

    I set up the code as you have called for but its not working on my site. Please see here. The lightbox on the left has a 5 second delay code. The lightbox on the right has no delay. However, they are both loading at the same time. Please help. See this page:

  • shilpi


    I am using this form and found it very interesting but you have not asked to mention my email id where the contact info will go?

    Hope you understand my question...
    please email on my id with answer.

    Many Thanks

  • townzcarz

    Hey how to change the form, i dont want form that you cr8 on lightbox form. and how to connect to database when we fill the form on popup?

  • Simon

    thanks for the code. My lightbox contains content from another html page. Any idea where I would put that into the code?

  • rajesh s

    Hi dude.

    How to send information via form through mail server ?
    how to edit source code ?

  • rajesh s

    Hi dude.

    Nice effect , I used source code but how to change text box and field name ? how to update drop down list box in form ?

  • IslandParadise

    The code I chose was "A" (the first option) and use an image/button in my widget area for the pop-up instead of the text link on some other my opinion, this is just too many clicks on the frontend and just degrades the look and flow of my site. Anyway, I got it to work in the widget area with a nice orange button as the link by placing the code right in the html of widget area (NOTE: I do not want it on the actual page). However the page the widget points to makes my slider gallery disappear! Which btw, any gallery plugin. Can someone tell me where do I actually put code "A" for my theme (I assume a PHP file or...??) or how to resolve jotform being in the widget area interfering with the slider gallery on the WP Page.

  • Jaydeep

    How to implement my form in this lightbox?

  • offersvalley

    i am using osclass script my site name is pls tell me how can i add this on my site

  • magicart87

    How do I set the lightbox autopopup to only appear one time within a user visit to site? Cookie settings?

  • abhijit

    The above code works perfectly, buy if I click outside the form anywhere on the page the form disappears. Is it possible that the form should disappear only when someone fills in the details and click on submit button?

  • guest_23322910503037

    Is it possible to get it to open on exit?