bethchis Posted November 24 Posted November 24 Hi there, I have two "Get in Touch" Buttons on my site https://www.greenhousecounselling.co.uk/ It currently is set up as hyperlink to send a email, however I would love if instead it could autoscroll someone down to the "get in touch" block of my website. Is there any way to make this possible? Or am I best to set up a secondary hidden page to redirect them to with the contact form. I'm just having issues with the "get in touch" buttons not linking out to anywhere. Thank you in advance! 🙂 B
Solution tuanphan Posted November 25 Solution Posted November 25 First, add a Code Block overlap this text Next, past this syntax into Code Block <div id="contact"></div> Next, edit Header Button >> Enter URL /#contact bethchis 1 Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
Squareko Posted November 26 Posted November 26 in your button add the section id like that, #section-one here section-one will be replaced according to your button id . For smooth scrolling you can add below code but it is optional. add this code into pages > web tools > code injeciton > footer: <script> document.addEventListener("DOMContentLoaded", function () { const links = document.querySelectorAll('a[href^="#"]'); // Select all anchor links links.forEach(link => { link.addEventListener("click", function (event) { event.preventDefault(); // Prevent default jump const targetId = this.getAttribute("href").substring(1); // Get the ID const targetElement = document.getElementById(targetId); if (targetElement) { targetElement.scrollIntoView({ behavior: "smooth", // Smooth scrolling block: "start" // Scroll to the top of the section }); } }); }); }); </script>
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment