Forum Discussion

Suchith's avatar
7 years ago

Open Search Result Link in New Tab.

Hi,

I am using search form component and I want to open search result link in new tab. I have written a jQuery function which adds the target attribute to the result anchor tab, but its still opening in the same window. 

Please let me know if i need to change any search component settings to open the link in new tab and also to avoid custom code to do the same.

Thanks.

  • Suchith

    No such settings or components to change the search behavior.  You have to do it forcefully using the script. 

    Give it a shot and check if it works in console. 

    • Suchith's avatar
      Suchith
      Ace

      Hi Vikas,

      I did it same way by adding target attribute to the anchor tag. I have shared the source code below.

      <a class="lia-link-navigation lia-js-autocomplete-list-item-link lia-autocomplete-message-list-item-link lia-component-forums-auto-complete-message-list-item" 
      tabindex="-1" id="link_0_37d75dea5d1a04_1dcf3" href="/t5/Account-Questions/How-to-Change-Account-Information/ta-p/265"
      target="_blank"><span class="lia-search-match-lithium">How</span> to Change Account Information</a>

      But this code still opening in the same tab.


      • Jake_N's avatar
        Jake_N
        Mentor

        Hi Suchith,

        That code is definitely correct. I have tested it in Internet Explorer, Mozilla Firefox, Chrome and Edge. If it isn't working for you I would suggest checking your browser settings or even check if you have another script on the page doing something else.

        You can stop any other javascript running on it typically by using preventDefault() or if you are using jQuery click here to view this page.

        Hopefully, this helps. If you are stuck do you mind posting what browser you are using?