MyListing Club

Open Listings in a New Browser Tab

Building better MyListing websites. One code snippet at a time.

Overview

The Open Listings in a New Browser Tab snippet allows for a better browsing experience within a MyListing website.

This allows your users to view one or many listings in a new tab, while not having to go back and reload the Explore page.

Implementation

  1. Grab the code snippet.
  2. Follow the provided instructions.
  3. Save your changes.
				
					
//// INSTRUCTIONS: 
//// Copy and paste the code snippet below into Theme Tools > Theme Options > Custom Code > JavaScript.

//// NOTES:
//// Replace the page IDs (000, 001...) below to reflect your Explore pages and add additional entries as needed,
//// so that ALL your Explore pages are accounted for. Page IDs can be found by inspecting your Explore pages
//// (Chrome > Right Click > Inspect).

--------------------------- CODE SNIPPET IS BELOW THIS LINE --------------------------- 

// OPEN LISTINGS IN A NEW BROWSER TAB
jQuery(function ($) {
  $("body.page-id-000, body.page-id-001").on(
    "click",
    ".lf-item > a",
    function (e) {
      e.preventDefault();
      window.open($(this).attr("href"), "_blank");
    }
  );
});