I’m trying to show a lightbox when people visit my website for the first time.
This is the code I have on my home page:
import {local} from 'wix-storage';
import wixWindow from 'wix-window';
$w.onReady(function () {
if(!local.getItem("lightboxShown")) {
ShowLightbox();
local.setItem("lightboxShown", "Yes");
}
});
function ShowLightbox() {
wixWindow.openLightbox("MyLightbox");
}
When I load the page on the published website, nothing happens. The lightbox is not showing. Curiously, it works on mobile, but not on PC. I tried calling openLightbox() in my onReady(), but it doesn’t work either. I am calling the lightbox using its name, not its ID. I really don’t understand what I am doing wrong, especially since it works on mobile (at least on Android) and in the editor preview.