My client just asked to verify the age of visitors, so I built a yes/no popup when people land on the site. They just got featured in Bloomberg which is cool! I was hoping someone might be able to help me with some custom code that:
if they answer yes, the popup does not show for 30 days
if they answer no, the popup shows for next visit
if they answer yes after previously selecting no on another visit, the popup does not show for 30 days
Oh, apologies - I forgot the two most important IDs!
Add an ID of btnYes to your “Yes” button and an ID of btnNo to your “No” button and let me know if that works. (Try it in incognito or clear your local storage before trying it again, just to be safe.)
Haha, I was reading though the script after I sent that and noticed I needed to make that change - thanks! Looks like it is remembering my yes/no answers now, but only the red box is hidden when someone returns after a yes answer - not the entire black overlay the red box in contained in. Should I give the overlay container the ID of “modal” instead?
On second thought, let me modify my code ever so slightly and then ping you to make one change here in a minute. For now, just remove the ID of modal from the red box element that it’s located at.
EDIT: Can you re-visit the link with the custom code and re-copy the code itself? I removed one line so that your fade out interaction upon clicking yes should still run. Also, once you do that, apply the ID of modal to the parent element, which is (as you said) the overlay container. (Be sure to remove it from the red box as well.)
Hey @mattvaru - was just retesting the site, and I found a small bug. Once the user clicks yes and the modal disappears, the user is still restricted from clicking on anything on the site. Any ideas to fix this? Thank you again!
EDIT: Sorry for the alarm, it was on my end with the interactions I had set on the Yes Button All good!
Hey @epicradness – apologies for the delay, didn’t see the notification here. Were you able to get this resolved? I went to your website and didn’t see the modal in the Navigator, so I figured you either found an alternate solution or are going to circle back to that piece later.
Hey @mattvaru thank you so much for posting this. I was trying to find a solution and it almost drove me mad. Haha.
Just one thing I’m trying to figure out: everything works like a charm on most devices and browsers. Only safari on Mac OS seems to ask for the age check every time a link within the site is clicked. Is this something that can be fixed or is safari blocking all cookies nowadays.
hey @mattvaru I am having a small problemthe thing is i have apreloader bg also witht the modal so what is happpening is the preloader is not getting removed by the js and only themodal is getting removed. so can u suggest me what should i do? Webflow - Copy of LP3
Hey @mattvaru, the page loads faster than the cookie, so when the cookie is activated I see the Age Verification for a few seconds before it disappear. Do you know how to solve this? Thanks for all the help!