Video Lightbox


Auto Open Video Lightbox

To automaticly open a video lightbox, add this code before the Video Lightbox plugin code:

<!-- Plugin Video Lightbox - Auto Open Video Lightbox -->
<!-- Author: Dmytro Kyselov https://dmytrokyselov.com/ -->
<script>!function(){function autoOpenVideoLightbox(){var element=document.querySelector(".js-auto-open-video-lightbox");if(!element)return null;element.style.display="none";var config={videoLink:element.getAttribute("data-video-link"),timeout:1e3*element.getAttribute("data-timeout"),createLink:element.getAttribute("data-create-link")},link=document.querySelector('a[href="'+config.videoLink+'"]');if(!link){if("yes"!==config.createLink)return null;link=createLink(config.videoLink),document.body.appendChild(link)}function createLink(href){var link=document.createElement("a");return link.setAttribute("href",href),link.style.display="none",link}setTimeout((function(){link.click()}),config.timeout)}document.addEventListener("DOMContentLoaded",autoOpenVideoLightbox),window.addEventListener("mercury:load",autoOpenVideoLightbox)}();</script>
<!-- end Plugin Video Lightbox - Auto Open Video Lightbox -->

Add the line below to Code Injection or to any page in a code block when Ajax Loading is enabled or to a page header code injection when Ajax Loading is disabled.

<div data-video-link="https://www.youtube.com/watch?v=QBQsKTNYPUE" data-timeout="2" data-create-link="no" class="js-auto-open-video-lightbox"></div>

Setup:

  • Replace the video link with your link in the data-video-link attribute.
  • Adjust the timeout (2 seconds by default) before opening the lightbox using the data-timeout attribute.
  • If you want to automatically create a video link, replace "no" with "yes" in the data-create-link attribute. In this case, if you leave the line in Code Injection, the video lightbox will be displayed on any page.
Previous
Previous

Mega Menu

Next
Next

Background video controls