How to have a ligthbox form in mobile browser

  • Chris
    Asked on November 11, 2016 at 8:23 PM
    the catch is I want the form to be 500 px wide on larger screens but only 250 wide on phones. is there a way to do this? would be great if I could just do 90% width but it doesn't seem to register % for lighthouse or feedback form. 
  • Elton Support Team Lead
    Replied on November 12, 2016 at 12:58 AM

    That's possible.

    1. First, you will have to create a form and get its lightbox embed code.

    http://www.jotform.com/help/220-How-to-Create-a-Lightbox-Form

    2. You will have to modify your lightbox embed code so it shows perfectly on mobile. To do just insert the following script after the script tag found in your lightbox embed code.

    var parentWidth = window.innerWidth;

    if(window.innerWidth <= 499) {parentWidth = window.innerWidth-100;} else {parentWidth =  500;}

    3. Then change the width value with this variable parentWidth

    This is how it would look like afterwards. Changes are highlighted in color light green.

    <script src="https://form.jotform.com/static/feedback2.js?3.3.REV" type="text/javascript">

        var parentWidth = window.innerWidth;

        if(window.innerWidth <= 499) {parentWidth = window.innerWidth-100;} else {parentWidth =  500;}

         var JFL_52935598338976 = new JotformFeedback({

           formId: '52935598338976',

           base: 'https://form.jotform.com/',

           windowTitle: 'My Form Title',

           background: '#2056c6',

           fontColor: '#FFFFFF',

           type: 'false',

           height: 500,

           width: parentWidth,

           openOnLoad: true

         });

    </script>

    If you need further assistance, let us know.

  • MBizTools
    Replied on November 12, 2016 at 8:44 AM

    That worked! Many thanks. I can work with that custom coding format. Much appreciated. I'll use on my other forms.