Hi folks, hoping someone can help me with a bit of guidance. I had a page with anchor points for my privacy policy. It was generated by a legal documents site based on my answers to a questionnaire and then gave me some html that simply worked without issues. it uses anchor points... however, zencart misunderstands them now and redirects to the home page instead of conveniently scrolling them to the relevant section. At some point between them initially being drafted 3 years ago and the anchor points working fine something must have changed as last night i realised they no longer work as expected when moving them over to my test site. I checked on the live site and they no longer function there either which is zen 1.57 series.
I've been trying to investigate it myself and seems it may be something to do with seo urls module and the way it generates said pages url? I tried to get a fix from chatgpt but it gave me an answer that was sort of great but a bit vague. it basically said that i should use java to create a listener that will correctly handle the link if it has a href anchor point. It also advised me it could likely cause issues and i should check if unsure... I was unsure at "java" the java it gave me is as follows...
Code:
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
targetElement.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
My thought is that potentially something previously existed which did this in zen which was removed or it was edited out for a reason im unaware of during the module dev that i've had done last year for a custom qr ticketing and event admissions module?
Bookmarks