Join

Open Single Listing Block Item Links in a New Browser Tab

Don't want to mess with code snippets? Request for this to be a feature of MyListing Pro.

Instructions

  1. Create a new JS code snippet.
  2. Copy the contents of code snippet below.
  3. Paste the contents into your code snippet.
  4. Review any notes that I’ve provided.
  5. Save and enable the code snippet.
  6. Test.

Snippet

Keeping people on your website is essential, and allowing external links to take people away from your website is typically not a good thing.

If you want to open every external link on your website in a new browser tab, you can use the Open All External Links in New Browser Tab code snippet.

Selectively Choose Blocks

Use the Block’s ID

This code snippet lets you selectively choose which Single Listing Block will have its external links opened in a new browser tab.

  1. Listing Type > Single Page > Content & Tabs > Edit the desired block.
  2. Custom Block ID > Enter any text for your ID.
  3. Add the code snippet below to your website.
  4. Within the code snippet, replace ‘custom-block-id’ with the ID you added to your Single Listing block.

If you want other Single Listing blocks’ items to open in a new browser tab, add the same ID to those blocks.

jQuery(document).ready(function ($) {
  $(".custom-block-class a").attr("target", "_blank");
});

Open Social Media Links in New Browser Tab

You can use the instructions in the previous section to do this, but here is another option that may be interesting. Just need to add the code snippet below to your website.

jQuery(document).ready(function ($) {
  $(".block-type-social_networks ul > li a").attr("target", "_blank");
});