External link not opening in new tab motion theme

Hi,

I have a footer menu that has items with an external link. I want to open them in a new tab. For this, I added the following code to the theme.js file.

var links = document.links;
for (let i = 0, linksLength = links.length ; i < linksLength ; i++) {
  if (links[i].hostname !== window.location.hostname) {
    links[i].target = '_blank';
    links[i].rel = 'noreferrer noopener';
  }
}

I can see on the Inspect that the code has injected target=“_blank” and rel=‘noreferrer noopener’ to the tag.
target ="_blank" is added

However, the link is still not opening in a new tab. How can I solve this problem? I am using Motion theme.

Thank you.

1 Like

@rupeshadh - can you please share this page link?

@rupeshadh

Sorry you are facing this issue, it would be my pleasure to help you.

Welcome to the Shopify community! :blush:
Thanks for your good question.

Please share your site URL,
I will check out the issue and provide you a solution here.

Hi Ketan,

The site URL is https://steelbrand.com.au/

Thank you.

Hi Suyash,

The site URL is https://steelbrand.com.au/

Thank you.