Jump to content

Open Lightbox Form on Page Load

Recommended Posts

I have a form block that is set up as a lightbox (so it opens when the button is clicked). I want the page to load with the lightbox open, so that the form functions more like a popup.

I'm trying to make this work in both 7.0 and 7.1, though I don't think that will make a ton of difference here. The promotional popup isn't an option here because it doesn't allow for the number of different things I need to collect from the person filling out the form.

I found a bit of script that seems like it should be steering me in the right direction, but the button itself doesn't have an ID, so I'm not sure how to make it work, or if there's a better way to do it.

<script> 
$(function () {
          window.onload = $('#submit_btn').click();
      });
</script>
Link to comment
14 minutes ago, AQP said:

I have a form block that is set up as a lightbox (so it opens when the button is clicked). I want the page to load with the lightbox open, so that the form functions more like a popup.

I'm trying to make this work in both 7.0 and 7.1, though I don't think that will make a ton of difference here. The promotional popup isn't an option here because it doesn't allow for the number of different things I need to collect from the person filling out the form.

I found a bit of script that seems like it should be steering me in the right direction, but the button itself doesn't have an ID, so I'm not sure how to make it work, or if there's a better way to do it.

<script> 
$(function () {
          window.onload = $('#submit_btn').click();
      });
</script>

What is your site url

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment
20 minutes ago, AQP said:

So I can't have the actual form up there until I've figured this out, but here's a dummy page with the same basic issue. If I can solve it there I can migrate it to where it needs to be.

Use this

<script> 
$(document).ready(function() {
	$("#block-yui_3_17_2_1_1636651045775_2157 button").click()
});
</script>

#block-yui_3_17_2_1_1636651045775_2157 is unique id of the lightbox button, you can use this extension to get it Squarespace ID Finder - Chrome Web Store (google.com)

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment
27 minutes ago, bangank36 said:

Use this

<script> 
$(document).ready(function() {
	$("#block-yui_3_17_2_1_1636651045775_2157 button").click()
});
</script>

#block-yui_3_17_2_1_1636651045775_2157 is unique id of the lightbox button, you can use this extension to get it Squarespace ID Finder - Chrome Web Store (google.com)

Awesome, thank you! I think I was looking one level too deep for the ID.

One more question: it's working in Firefox, but not in Safari. Is there something I can do to make it work in both, or is that just Safari being weird and I have to live with it? (The form still opens when you manually click the button in Safari, it just doesn't load opened.)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.