PUMCSBH Posted October 27, 2023 Posted October 27, 2023 I wanted to make our entire Cover Page a clickable link. I have code for it, but I don't want to include the Social Buttons. Can someone help me write the code so that the Social Buttons still work? Page in question: https://www.puyallupumc.org. Squarespace version 7.0. <body onclick="window.location.href='newpage.html';" style="cursor:pointer; width:100%; height:100%;"></body> Thank you!
Inspirerd Posted October 27, 2023 Posted October 27, 2023 (edited) Hey @PUMCSBH! Here you go! let elementsArray = document.querySelector(".sqs-slide-layer.layer-front"); if (elementsArray) { elementsArray.style.cursor = "pointer"; elementsArray.addEventListener("click", function (event) { let targetElement = event.target; while (targetElement) { if (targetElement.tagName === 'A') { // It's a link, allow the default behavior return; } targetElement = targetElement.parentElement; } window.location.href = 'home'; }); } You don't need the code you mentioned. This adds a listener for a click on the slide but checks to make sure the click event didn't happen inside a link element. Hope this helps! Edited October 28, 2023 by Inspirerd melody495 and tuanphan 2 Daniel Rodrigues | Excito LLC Squarespace Web Design for Photographers & Creatives 🌐 https://www.excitollc.com/ | ✉ Contact Me: daniel@excitollc.com 💡 Squarespace Enthusiast | 📖 Squarespace Design Blog for Photographers 🤝 Always happy to help and collaborate! Connect with me on LinkedIn.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment