Hi all,
I want to make it so that my lightbox – entitled “email” – only shows one time per machine. Once they click close, I don’t want them to see it again. I believe I have the code written properly, but it’s not behaving the
way in which it should. I’ve attached a screenshot that shows the code and also clearly demonstrates my lightbox is simply named “email”.
Any guidance would be appreciated. Thanks!
P.S. If I want to make a second lightbox behave this same way, what would I add/change/edit to the code to accomplish this?
Hey, @statesidecannabisinv
This should work:
// For full API documentation, including code examples, visit https://wix.to/94BuAAs
import wixWindow from 'wix-window';
import { local } from 'wix-storage';
$w.onReady(function () {
let isFirstTime = local.getItem("firstTimePopupShown");
if (!isFirstTime) {
wixWindow.openLightbox("email")
.then((data) => {
let receivedData = data;
local.setItem("firstTimePopupShown", true);
});
} else {
console.log("Not first time");
}
});
Please note, next time upload your code and not the image ![:slight_smile: :slight_smile:](https://emoji.discourse-cdn.com/google_classic/slight_smile.png?v=12)
B.
Hi B,
I just uploaded that code to my website and the pop-up is still behaving the same way. You could see for yourself if you simply go to this link and wait 20-30 seconds.
I have just tested that tutorial and it all works fine.
Make sure that you do what is stated in the ‘Popup’ section of it.
We don’t want the lightbox to appear unless we specifically open it using code. To make sure the lightbox doesn’t open automatically, select the lightbox and click the Set Triggers button. Set the lightbox so that it does not automatically display on pages.
Thank you both for your assistance. I had forgotten to disable the “always display” trigger – that appeared to be my issue.
However, one final question: am I able to add in further code that would make it so ~10 seconds must elapse before the pop-up box is shown?
Hi B,
How do I make it so a lightbox does not display on mobile at all? I don’t have any such feature available to me in the mobile editor.
Hi GOS,
How do I make it so a lightbox does not display on mobile at all? I don’t have any such feature available to me in the mobile editor.
@statesidecannabisinv
For delaying lightbox, you can do that in the lightbox settings itself and it is explained in a previous post here or you can use setTimeout and do it with code.
https://www.wix.com/corvid/forum/community-discussion/removing-the-delay-of-a-lightbox
https://www.wix.com/corvid/forum/community-discussion/set-timeout-for-lightbox
Make sure that you read about lightboxes on mobiles too.
https://support.wix.com/en/article/editing-your-lightbox-in-the-mobile-editor
Note:
The delay timer on your Lightbox begins once the site is fully loaded. If you have set your delay timer to 0, you may still experience a slight delay while the site is loading.