Jump to content

Index Page Link to New Tab Breaks Ajax Loading when Using Custom Code Injection

Recommended Posts

Hi, I'm currently using an Index page to link to a number of projects. I've used custom code injection from this resource (thank you Tuan) to link an image on index and a link in the footer to open an external website in a new tab. This function works as desired with Ajax Loading turned off, but ideally I'd like it to function with Ajax on as well.

With Ajax Loading turned on, the original Index page shows a blank screen upon clicking the link (image below). The custom link function also stops working after running through the site a bit. Is there a way to avoid the blank screen or to ensure the link functions even with Ajax on? Thanks for your help!

Source: zaneliu.com/work and click on the second image (Wayfinding on Ai Pin) for error

Ajax breaking on link click:



My Custom Code Injection:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
$(document).ready(function() {
  // open image link new tab
  $('article.index-item a[href="/wayfinding-humane"]').attr('target','_blank');
  // open footer link new tab
  $('a.index-nav-link[href="/wayfinding-humane"], .page-description a, div#collection-footer-6518953523d07e0831e2e9bd a').attr('target','_blank');
  // Humane image
  $('article.index-item a[href="/wayfinding-humane"]').attr('href','https://michaelandzanes.website');
  // Bottom link for Humane


Edited by zaneliu
Link to comment
  • zaneliu changed the title to Index Page Link to New Tab Breaks Ajax Loading when Using Custom Code Injection
  • Replies 0
  • Views 1.1k
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

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.