Hi to all.
I’m newbie about coding and JS.
I need to add a popup with “age verification” inside the SITE code.
A simple question that ask if the user is over or under 18 years old.
With 2 buttons 1 to accept and continue to the site, 2 to leave.
I need this features:
- The popup must appear EVER in any page of the site.
- Must have a dark overlay that hide the contents of the page
- It must not be bypassed or skypped in any way
- When the user click on “+18” buttons, the confirmation are saved on storage session of the browser and the popup will not appear until the end of the session
- The portion of the code must be executed before the loading of page elements (and other lightbox) and before another script that i need in the page.
I tryed with a normal lightbox in wix and then i added this code to the SITE panel:
setTimeout( function () {
if (!session.getItem(“firstTimePopupShown”)) {
// open popup
wixWindow.openLightbox(“alert18”);
// set flag for future visits
session.setItem(“firstTimePopupShown”, “yes”);
}
// The timeout value is 300 nanoseconds
},
300);
Unfortunately this is not good for my purpose:
when the user leave the page and press back button on the browser…the script read the label “firstTimePopupShown” in the session storage, and never appear.
So i think that i need to add “session.setItem” as a fuction to the button +18 of the lightbox.
In this case the script add the label to the session storage only if the user confirm that is older than 18y.
But I have no idea to do this.
Please…anyone can help me?
Thanks so much.