This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Open custom_url in new tab

#6155
Ernest MarcinkoErnest Marcinko
Keymaster

Hi!

If I understand correctly, you want to open the only the custom URLs in a new window. Well, there is an option to open all links in a new tab on the Layout Options -> Results behavior panel. (first option)

First of all, enable that option so everything is redirected to a new window.

Then, try using this custom Javascript method:

[code]
$(function() {
$(‘.results’).on(‘click’, ‘.asp_isotopic_item’ , function(e) {

var thisDomain = "offthestreets.co.uk";
var url = $(‘.asp_content > h3 > a’, this).attr(‘href’);

// If it is a local url, prevent opening a new tab, open directly
if (url.indexOf(thisDomain) > -1) {
e.preventDefault();
e.stopPropagation();
location.href = url;
}

return true;
});
});
[/code]

It basically attaches a function to the click event of the result item. Then checks if the item url is local or not. If local, then aborts the default operation (opening to a new tab) and instead it opens to the local window. Not sure how this is going to work, but this is the best idea I can think of, which does not include modifying the plugin code.