ÈËÉú¾ÍÊDz©¡¤(Öйú)×ðÁúAGÆì½¢Ìü

ÈËÉú¾ÍÊDz©¡¤(Öйú)×ðÁúAGÆì½¢Ìü(LianLian Global)¹ÙÍøÊ×Ò³

shopifyÔÚбêÇ©Öз­¿ªÍⲿÁ´½ÓÒÔ¼°Ìí¼Ó´úÂë°ì·¨

2022/03/04
×Ô½¨Õ¾

ÔÚбêÇ©Öз­¿ªÍⲿÁ´½Ó

±¸×¢

ÈôÊÇÄúʹÓàShopify µÄÃâ·ÑÄ£°å£¬£¬£¬£¬£¬£¬Äú¿ÉÒÔÁªÏµ Shopify Ö§³ÖÍŶӻñµÃ¹ØÓڴ˽̵̳Ä×ÊÖú¡£¡£¡£¡£¡£¡£´Ë½Ì³ÌÐèÒª 15 ·ÖÖÓµÄÉè¼ÆÊ±¼ä¡£¡£¡£¡£¡£¡£ÈôÒªÏàʶÏêÇ飬£¬£¬£¬£¬£¬Çë²ÎÔÄ Support for themes¡£¡£¡£¡£¡£¡£

±¸×¢

´Ë×Ô½ç˵ÓÃÓÚ¸´¹Å Shopify Ä£°å£¬£¬£¬£¬£¬£¬²»ÊÊÓÃÓÚ¡°Online Store 2.0¡±Ä£°å¡£¡£¡£¡£¡£¡£

  • ÕÒµ½ÄúµÄÄ£°å¼Ü¹¹°æ±¾

  • ̽Ë÷¡°Online Store 2.0¡±Ä£°å×Ô½ç˵

Äú¿ÉÒÔÏòÄ£°åÖÐÌí¼ÓһЩ´úÂ룬£¬£¬£¬£¬£¬ÓÃÓÚʹÄúÔÚÏßÊÐËÁÖеÄÍⲿÁ´½ÓÔÚеÄä¯ÀÀÆ÷±êÇ©Öз­¿ª¡£¡£¡£¡£¡£¡£ÕâÑù×ö¿ÉÄܺÜÓÐ×ÊÖú£¬£¬£¬£¬£¬£¬ÓÉÓÚÕâÓÐÖúÓÚ±ÜÃâ¿Í»§ÍÑÀëÄúµÄÔÚÏßÊÐËÁ¡£¡£¡£¡£¡£¡£ÍⲿÁ´½ÓÊǽ«¿Í»§¶¨Ïòµ½ÆäËûÍøÕ¾µÄ URL£¬£¬£¬£¬£¬£¬ÀýÈçÉ罻ýÌåͼ±êÖаüÀ¨µÄÁ´½Ó¡£¡£¡£¡£¡£¡£

½«Ò»Ð©´úÂëÌí¼Óµ½ÄúÄ£°åµÄ JavaScript ÎļþÖÐ

ÈôÒªÔÚеÄä¯ÀÀÆ÷±êÇ©Öз­¿ªÍⲿÁ´½Ó£¬£¬£¬£¬£¬£¬ÄúÐèÒª±à¼­Ä£°åµÄ JavaScript Îļþ¡£¡£¡£¡£¡£¡£

PC£º

  1. ÔÚ Shopify ºǫ́ÖУ¬£¬£¬£¬£¬£¬×ªµ½ÔÚÏßÊÐËÁ > Ä£°å¡£¡£¡£¡£¡£¡£

  2. ÕÒµ½Òª±à¼­µÄÄ£°å£¬£¬£¬£¬£¬£¬È»ºóµã»÷²Ù×÷ > ±à¼­´úÂë¡£¡£¡£¡£¡£¡£

  1. ÔÚ Assets Ä¿Â¼ÖУ¬£¬£¬£¬£¬£¬µã»÷ÒÔÏÂÒ»Ï

theme.js - theme.js.liquid - custom.js

  1. ½«ÒÔÏ´úÂëÕ³Ìùµ½Îļþµ×²¿£º

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';   } }
  1. µã»÷ÉúÑÄ¡£¡£¡£¡£¡£¡£

Æ»¹ûϵͳ£º

  1. ÔÚ Shopify Ó¦ÓÃÖУ¬£¬£¬£¬£¬£¬Çá´¥ÊÐËÁ¡£¡£¡£¡£¡£¡£

  2. ÔÚÏúÊÛÇþµÀ²¿·ÖÖУ¬£¬£¬£¬£¬£¬Çá´¥ÔÚÏßÊÐËÁ¡£¡£¡£¡£¡£¡£

  3. Çá´¥ Manage themes£¨ÖÎÀíÄ£°å£©¡£¡£¡£¡£¡£¡£

  4. ÕÒµ½Òª±à¼­µÄÄ£°å£¬£¬£¬£¬£¬£¬È»ºóµã»÷²Ù×÷ > ±à¼­´úÂë¡£¡£¡£¡£¡£¡£

  1. ÔÚ Assets Ä¿Â¼ÖУ¬£¬£¬£¬£¬£¬µã»÷ÒÔÏÂÒ»Ï

theme.js - theme.js.liquid - custom.js

  1. ½«ÒÔÏ´úÂëÕ³Ìùµ½Îļþµ×²¿£º

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';   } }
  1. µã»÷ÉúÑÄ¡£¡£¡£¡£¡£¡£

°²×¿ÏµÍ³£º

  1. ÔÚ Shopify Ó¦ÓÃÖУ¬£¬£¬£¬£¬£¬Çá´¥ÊÐËÁ¡£¡£¡£¡£¡£¡£

  2. ÔÚÏúÊÛÇþµÀ²¿·ÖÖУ¬£¬£¬£¬£¬£¬Çá´¥ÔÚÏßÊÐËÁ¡£¡£¡£¡£¡£¡£

  3. Çá´¥ Manage themes£¨ÖÎÀíÄ£°å£©¡£¡£¡£¡£¡£¡£

  4. ÕÒµ½Òª±à¼­µÄÄ£°å£¬£¬£¬£¬£¬£¬È»ºóµã»÷²Ù×÷ > ±à¼­´úÂë¡£¡£¡£¡£¡£¡£

  1. ÔÚ Assets Ä¿Â¼ÖУ¬£¬£¬£¬£¬£¬µã»÷ÒÔÏÂÒ»Ï

theme.js - theme.js.liquid - custom.js

  1. ½«ÒÔÏ´úÂëÕ³Ìùµ½Îļþµ×²¿£º

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';   } }
  1. µã»÷ÉúÑÄ¡£¡£¡£¡£¡£¡£

ShopifyÉÌ»§¹ÙÍøÔ­ÎÄÏêÇ飺

Open external links in a new tab

Note

If you use a free theme from Shopify, then you might be able to contact Shopify Support for help with this tutorial. It requires 15 minutes of design time. To learn more, refer to Support for themes.

Note

This customization is for vintage Shopify themes, and doesn't apply to Online Store 2.0 themes.

  • Find out your theme's architecture version

  • Explore Online Store 2.0 theme customizations

You can add some code to your theme that causes external links on your online store to open in a new browser tab. This can be beneficial because it helps to prevent customers from navigating away from your online store. External links are URLs that direct customers to different websites, such as the links included in social media icons.

Add some code to your theme's JavaScript file

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

PC£º

  1. From your Shopify admin, go to Online Store > Themes.

  2. Find the theme you want to edit, and then click Actions > Edit code.

  1. In the Assets directory, click one of the following:

    • theme.js

    • theme.js.liquid

    • custom.js

  2. 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';   } }
  3. Click Save.

iPhone£º

  1. From the Shopify app, tap Store.

  2. In the Sales channels section, tap Online Store.

  3. Tap Manage themes.

  4. Find the theme you want to edit, and then click Actions > Edit code.

  1. In the Assets directory, click one of the following:

    • theme.js

    • theme.js.liquid

    • custom.js

  2. 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';   } }
  3. Click Save.

Android£º

  1. From the Shopify app, tap Store.

  2. In the Sales channels section, tap Online Store.

  3. Tap Manage themes.

  4. Find the theme you want to edit, and then click Actions > Edit code.

  1. In the Assets directory, click one of the following:

    • theme.js

    • theme.js.liquid

    • custom.js

  2. 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';   } }
  3. Click Save.

ÎÄÕÂÄÚÈÝȪԴ£ºShopifyÉÌ»§¹Ù·½ÍøÕ¾


¸ü¶à
¡¾ÍøÕ¾µØÍ¼¡¿¡¾sitemap¡¿