none
Open Library view/List view items/documents in new tab in sharepoint online

    Question

  • We have document library and we added library view on a different page. However when we click on documents from library view then open in same window. Is it possible to make them open in new tab from sharepoint online library and list views ?

    Dhaval Raval

    Friday, March 17, 2017 8:22 PM

All replies

  • Hi Dhaval Raval,

    There are two methods to open the item/document in a new tab when clicking the item/document link.

    1. Hold down the CTRL key when clicking the link.

    2. Add script to overwrite the “target” attribute for “<a>” link.

    For example:

    Overwrite the “target” attribute for hyperlinks in the second column (Title).


    <script type="text/javascript" src="../../SiteAssets/js/jquery-1.10.2.min.js"></script>
    
    <script type="text/javascript">
    
    $(function() {
    
            var $t = $("table.ms-listviewtable>tbody tr td:nth-child(2) a");
    
            $t.each(function(){
    
                  $(this).attr("target", "_blank");
    
             });
    
    });
    
    </script>


    Best regards,

    Linda Zhang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, March 20, 2017 9:04 AM
  • Ctrl + click doesn't work on all browsers. It only works on IE. Above script doesnt seem to add target attribute to <a> when I look at rendered HTML

    Dhaval Raval

    Monday, March 20, 2017 8:34 PM
  • Hi Dhaval Raval,

    Please check the console to see if there are some errors.

    Make sure you have included the jQuery JavaScript Library.

    You need to modify the script a bit for applying to your list/library.

    1. Change “<script type="text/javascript" src="../../SiteAssets/js/jquery-1.10.2.min.js"></script>”.

    2. Modify var $t = $("table.ms-listviewtable>tbody tr td:nth-child(2) a"); based on your column.


    Best Regards,

    Linda Zhang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, March 21, 2017 1:30 AM
  • Hi Dhaval Raval,

    How are things going?

    Does the script work?

    Best regards,

    Linda Zhang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Friday, March 24, 2017 1:13 AM
  • I havent tried yet, I will let you know

    Dhaval Raval

    Friday, March 24, 2017 8:05 PM