Open all external l...
 
Notifications
Clear all

[Solved] Open all external links in a new tab

3 Posts
2 Users
1 Reactions
2,543 Views
Susanclark
(@susanclark)
Eminent Member
Joined: 5 years ago
Posts: 38
Topic starter  

Hi,

i have some external links on my shopify store that need to open in a new tab, is there way to open all external links in a new tab ?

Note : I use Plak

Thanks in advance


   
Quote
plaktheme
(@plaktheme)
Reputable Member
Joined: 5 years ago
Posts: 0
 

Hi Susan,

Katrine here from Plak Theme Support

In order to have external links open in a new tab, you need to edit your Plak theme's JavaScript file.

  • In the Assets directory, open the file vendor.js 
  • Paste the following code at the bottom of the 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';
}
}
  • Click Save

 

Kind regards,

Katrine| Plak theme support
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as a Solved Solution

Katrine | Technical support at Plak, Scrowp & Vantout
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as a Solved Solution


   
Susanclark reacted
ReplyQuote
Susanclark
(@susanclark)
Eminent Member
Joined: 5 years ago
Posts: 38
Topic starter  

It works great ! Thank you once again Katrine for your help

Susan 🙂


   
ReplyQuote
Share:

Welcome to the Shopify Forum Community provided by Plak ThemeLLC, a place where you can discuss about eCommerce and Shopify, solve technical issues, get help with Shopify Design, Apps integration, Marketing, Facebooks ad, Google ads and more.

Before posting, we invite you to read and follow the forum rules | We also support any questions related to Free Shopify themes :Dawn, Express, Minimal, Brooklyn, Narrative, Supply, Debut, Venture, Boundless and Simple