Jump to content

Links Open in New Tab Desktop Only

Recommended Posts

Site URL: https://sisterswhohustle.co/

I'm trying to figure out how to make text links and image links open in a new window on DESKTOP ONLY.

But I'd like these same text links and image links to open in the same window on mobile.

I'm using the SKYE template. Is this possible?

Reason being, all my external links go to Amazon to push affiliate sales. If I have "open in a new window" turned on, the links won't automatically open in the Amazon app on mobile and I need them to. But when I uncheck "open in a new window", they DO open in the Amazon shopping app automatically on mobile, but redirect away from my website on desktop.

Thanks in advance!

Link to comment
  • Replies 5
  • Views 915
  • Created
  • Last Reply
8 hours ago, brooxie said:

OK, I just upgraded to a business plan. 

What's the code I need to add and where?

Thank you for your help!!

Try adding to Home > Settings > Advanced > Code Injection > Footer

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
  // by tuan phan - squarespace forum
  $(document).ready(function() {
    if (jQuery(window).width() < 640) {
    $(".html-block a").attr('target','_self');
    }
});
</script>

 

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!)

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.