Open external links in new window

Solved

Open external links in new window

technase
Shopify Partner
165 1 39

Hi,
I need help modifying the last link in the header and the social buttons in the footer so that they open in a new window when clicked. Currently, they are opening in the same window.
store link: https://testingstoresandthemes.myshopify.com/
password: lock
Attaching a screenshot for reference.  

screencapture-testingstoresandthemes-myshopify-2024-09-28-12_11_28 copy.jpg

technase
Accepted Solutions (2)

BSSCommerce-HDL
Shopify Partner
2298 847 1061

This is an accepted solution.

Hi @technase

Step 1: Go to Shopify Admin -> Online Store ->Theme -> Edit code

Step 2: Search file theme.liquid

Step 3: Insert this code above </body> tag:

BSSCommerceHDL_0-1727509476459.png

 

 

<script>
let social_links = document.querySelectorAll('.footer__list-social .list-social__item a');
if(social_links.length > 0) {
   social_links.forEach(link => {
     link.setAttribute('target', '_blank');
   });
}
</script>

 

 

Hope this can help you,

If our suggestions are useful, please let us know by giving it a like or marking it as a solution. Thank you 😍

 

Sale banner, pop ups: Customize your sale banner, pop-ups and create countdown bar to boost conversion rate.
Simicart: Transform your Shopify store into a stunning and fully functional mobile app with just a few simple steps.
Product Labels & Badges:
Get more sales with striking labels, badges, and banners from our 10,000+ available templates.

BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now

View solution in original post

BSSCommerce-HDL
Shopify Partner
2298 847 1061

This is an accepted solution.

Hi @technase, Pls try with this code: 

<script>
let social_link_header = document.querySelector('#HeaderMenu-retail-store');
if(social_link_header) {
   social_link_header.setAttribute('target', '_blank');
}
</script>

Hope this can help you,

If our suggestions are useful, please let us know by giving it a like or marking it as a solution. Thank you 😍

Sale banner, pop ups: Customize your sale banner, pop-ups and create countdown bar to boost conversion rate.
Simicart: Transform your Shopify store into a stunning and fully functional mobile app with just a few simple steps.
Product Labels & Badges:
Get more sales with striking labels, badges, and banners from our 10,000+ available templates.

BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now

View solution in original post

Replies 7 (7)

BSSCommerce-HDL
Shopify Partner
2298 847 1061

This is an accepted solution.

Hi @technase

Step 1: Go to Shopify Admin -> Online Store ->Theme -> Edit code

Step 2: Search file theme.liquid

Step 3: Insert this code above </body> tag:

BSSCommerceHDL_0-1727509476459.png

 

 

<script>
let social_links = document.querySelectorAll('.footer__list-social .list-social__item a');
if(social_links.length > 0) {
   social_links.forEach(link => {
     link.setAttribute('target', '_blank');
   });
}
</script>

 

 

Hope this can help you,

If our suggestions are useful, please let us know by giving it a like or marking it as a solution. Thank you 😍

 

Sale banner, pop ups: Customize your sale banner, pop-ups and create countdown bar to boost conversion rate.
Simicart: Transform your Shopify store into a stunning and fully functional mobile app with just a few simple steps.
Product Labels & Badges:
Get more sales with striking labels, badges, and banners from our 10,000+ available templates.

BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now

technase
Shopify Partner
165 1 39

Thank you.. it addresses the links in the footer but the one in header still opens in same window. 

technase
BSSCommerce-HDL
Shopify Partner
2298 847 1061

Hi @technase

Step 1: Go to Shopify Admin -> Online Store ->Theme -> Edit code

Step 2: Search file theme.liquid

Step 3: Insert this code above </body> tag:

<script>
let social_link_header = document.querySelector('#HeaderMenu-social');
if(social_link_header) {
   social_link_header.setAttribute('target', '_blank');
}
</script>

 

Hope this can help you,

If our suggestions are useful, please let us know by giving it a like or marking it as a solution. Thank you  😍

Sale banner, pop ups: Customize your sale banner, pop-ups and create countdown bar to boost conversion rate.
Simicart: Transform your Shopify store into a stunning and fully functional mobile app with just a few simple steps.
Product Labels & Badges:
Get more sales with striking labels, badges, and banners from our 10,000+ available templates.

BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now

technase
Shopify Partner
165 1 39

Hey, 

I am so sorry, I updated the menu item title and link, and this code seems to be not working. Would you be able to provide me with the updated code to resolve this?
Thank you so much for all your help!

technase
BSSCommerce-HDL
Shopify Partner
2298 847 1061

This is an accepted solution.

Hi @technase, Pls try with this code: 

<script>
let social_link_header = document.querySelector('#HeaderMenu-retail-store');
if(social_link_header) {
   social_link_header.setAttribute('target', '_blank');
}
</script>

Hope this can help you,

If our suggestions are useful, please let us know by giving it a like or marking it as a solution. Thank you 😍

Sale banner, pop ups: Customize your sale banner, pop-ups and create countdown bar to boost conversion rate.
Simicart: Transform your Shopify store into a stunning and fully functional mobile app with just a few simple steps.
Product Labels & Badges:
Get more sales with striking labels, badges, and banners from our 10,000+ available templates.

BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now

technase
Shopify Partner
165 1 39

Thank you so much ❤️

technase
BSSCommerce-HDL
Shopify Partner
2298 847 1061

@technase, No problem. Have a good day 😍

Sale banner, pop ups: Customize your sale banner, pop-ups and create countdown bar to boost conversion rate.
Simicart: Transform your Shopify store into a stunning and fully functional mobile app with just a few simple steps.
Product Labels & Badges:
Get more sales with striking labels, badges, and banners from our 10,000+ available templates.

BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now