Jump to content

FORTE Template - How to open a clickthrough URL in a new tab

Recommended Posts

23 minutes ago, angelinapilarinos said:

Site URL: https://www.angelinapilarinos.com/

Hi I have several gallery pages that have clickthrough URLs connected to my smugmug account.  When you click on the image I want a new tab to open to my smugmug page.  At the moment it is not opening in a new tab.  Can someone tell me what code I need to use to make these links open in a new tab?  Thank you!

Kindly add this snippet to Settings->Advanced->Code Injection->Header

<script>
  document.addEventListener('DOMContentLoaded', function() {
        var slides = document.querySelectorAll(".slide [data-click-through-url]")
        for (var slides of slides) {
            slides.addEventListener('click', function(e) {
                var url = this.getAttribute("data-click-through-url");
                console.log(url);
                if (url) {
                    e.preventDefault();
                    e.stopPropagation();
                    window.open(url, '_blank');
                }

            })
        }
  });
</script>

 

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Keyword Highlighter
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.