2

Ive implemented a SharePoint 2013 Farm Wide search for my site collections, and now want the URL's that get returned to open up in a new tab.

Is there a relatively effortless way to do this rather than messing with the display template, or is that the recommended way?

Thanks!

3 Answers 3

1

Good day!

If this is for a search results webpart (like results.aspx), than what I found easiest was to add a content editor at the bottom of the page and add a little jquery to achieve this. You can use something like this:

<script type="text/javascript">
$(".ms-srch-item-link").attr("target","_blank");
</script>

This jquery will target all hyperlinks that appear in the search results webpart and change their attributes to open in a new tab. No messing with display templates.

1
  • 1) $(".ms-srch-item-link").length = 0. 2) when paging in not firing. this code called just once on page load.
    – WantToDo
    Oct 24, 2019 at 11:20
0

you can override the default template rather easy - or you could add a jquery script to the search result page that handles the click event.

0

add script editor webpart

<script type="text/javascript">
 $(document).ready(function(){
     $('body').on('DOMNodeInserted',".ms-srch-item-link",function(e){
         $(e.target).attr("target","_blank");
     })
 })
</script>  

good for ajax paging of search results webpart

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.