Open Lightbox on Pageload
Automatically open Webflow's native lightbox on page load via this Javascript code snippet. Adding a parameter to your website URL allows for the lightbox to automatically be shown on page load.
Automatically open Webflow's native lightbox on page load via this Javascript code snippet. Adding a parameter to your website URL allows for the lightbox to automatically be shown on page load.
How to add it
- Give the lightbox button a unique class of btn-video
- Link to the parameter in the Javascript code (#video)
- Add the Javascript code to your closing body tag of your pages custom code settings
The code
Javascript
<!-- Add to closing body tag -->
<script>
$(function() {
if (document.location.href.indexOf('#video') > 0) {
$('.btn-video').first().trigger('tap');
}
});
</script>