Jump to content

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

Recommended Posts

Posted (edited)

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:

image.thumb.png.9c486909f31c0cb40ce6efaabf391809.png

 

My Custom Code Injection:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<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
  $('a.index-nav-link[href="/wayfinding-humane"]').attr('href','https://michaelandzanes.website');
});
</script>

 

Edited by zaneliu
  • 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.