Plugin Author
Phil
(@philsbury)
If you know what the hash needs to be, you can do:
window.addEventListener('age_gate_passed', event => window.location.hash = 'section-2');
If you don’t know what it is, there may still be a way to do it, so let me know
Thanks!! I was able to make it work with that event. I got the hash directly from the URL since there are multiple anchors as options. I also added a delay because it was redirecting to the top at first.
window.addEventListener('age_gate_passed', function() {
// Get the hash from the current URL
var hash = window.location.hash;
// Check if the hash is not empty
if (hash) {
// Decode the hash to handle special characters
var decodedHash = decodeURIComponent(hash);
// Remove the '#' character from the decoded hash
var targetId = decodedHash.substring(1);
// Delay the scroll
setTimeout(function() {
// Scroll to the section with the target ID
var targetSection = document.getElementById(targetId);
if (targetSection) {
targetSection.scrollIntoView({ behavior: 'smooth' });
}
}, 1500); // Scroll after 1.5 seconds
}
});