Age Verification | Squarespace
document.getElementById('confirm-age').onclick = function() localStorage.setItem('ageVerified', 'true'); document.getElementById('age-verification-modal').style.display = 'none'; ;
document.getElementById('deny-age').onclick = function() window.location.href = 'https://www.google.com'; // Redirect away ; </script> The above remembers verification via browser localStorage . To reset daily, replace the if condition with: age verification squarespace
Paste this (customize the age threshold and link): document
And on confirm:
<div id="age-verification-modal" style="position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.9); z-index:9999; display:flex; align-items:center; justify-content:center; color:white; font-family:sans-serif;"> <div style="background:#1a1a1a; padding:2rem; border-radius:12px; text-align:center; max-width:400px;"> <h2>Age Verification Required</h2> <p>You must be 21+ to access this site.</p> <button id="confirm-age" style="background:#4CAF50; color:white; padding:10px 20px; border:none; border-radius:5px; cursor:pointer;">I am 21 or older</button> <button id="deny-age" style="background:#f44336; color:white; padding:10px 20px; border:none; border-radius:5px; margin-left:10px; cursor:pointer;">I am under 21</button> </div> </div> <script> if(!localStorage.getItem('ageVerified')) document.getElementById('age-verification-modal').style.display = 'flex'; // Redirect away
const lastCheck = localStorage.getItem('ageVerifiedDate'); const today = new Date().toDateString(); if(lastCheck !== today) // show modal