top of page
Anchor 1

Wix Tutorial - Adding an URL to a Lightbox using Wix Code

Sometimes it can be handy to have a lightbox have a URL. For instance, in case you send out emails with a link in your signature to a video on your site. You can add the video to a lightbox and only have it show when someone clicks the link to it in your email signature.

Elements:

Lightbox name: urlExample

Wix Code:

import wixWindow from 'wix-window';
import wixLocation from 'wix-location';
function open_Lightbox(){
let query = wixLocation.query;
var goto = query.name;
wixWindow.openLightbox(goto);
}
$w.onReady(function () {
open_Lightbox();
});

The lightbox then will have the following URL:
domainname/?name=lightboxname

Once the code is on a page you can use the URL with any lightbox. If you would like the lightbox to appear when opening another page (not your home page), make sure you add the code to that page and use the following URL:
domainname/pagename/?name=lightboxname

Demo:

On this page, Wix Code has been used to show a Lightbox named urlExample.

 

The above code was used:

Example Wix Code Lightbox with URL

To open the lightbox, click the following URL:

​

https://www.wixcreate.com/adding-a-url-to-a-lightbox/?name=urlExample

bottom of page