Is there any easy way to open the document library files in a new window or popup depending on the file types?

e.g. PDF - In Adobe reader (currently opens in IE)

Image file (currently opens in IE)

4 Answers 4


I used the below to do this.

<script type="text/javascript">
$('.s4-ba a').attr("target", "_blank")
$('.s4-ba a').removeAttr("onclick");

It's working for me in SharePoint 2013


Insert a content editor and add the following code,

function () {
    // has to be on an interval for grouped doc libraries
    // where the actual links are loaded only once a group
    // is expanded
        function () {
            $("a[onclick*=’return DispEx’][target!=’_blank’]")
                .attr("target", "_blank")

            // document type icons
                .click(function (e) {
                    window.open($(this).attr("documentUrl"), "_blank");
                    return false;
                .each(function () {
                            .replace(/["'{}]/g, "")
                    this.onclick = null;


  • Please don’t add just a link as answer to a question. If the link breaks, the answer you provided will not be useful for future visitors. Provide an answer of your own and use the link as reference. If needed, you can block quote the content from your link. More information is found in our help center, especially How do I write a good answer
    – Benny Skogberg
    Commented Feb 16, 2016 at 20:10

It can be possible to open files in new window in Internet Explorer itself, have to modify little bit XSLT (as need to add _blank='true') in ListViewWebpart embedded in list view page itself.

Yes, design mode is not available. I am not saying to open design mode.

  1. Open library in sharepoint designer.
  2. Click 'Advanced' in Home tab.
  3. Markup will be visible, select the XsltListVievWebpart tag from start to end
  4. By doing 3) step, a new tab appear named "List View tools".
  5. Within that tab go to Design options and click 'customize xslt'
  6. Check xsl will now render, search by Verifyhref
  7. Add _blank='true' there.

After the operation performed from screenshot, perform step 6 and 7 and do preview the page in browser from SPD itself.

Here are some screenshots:

First part First PArt

Second partSecond part

  • what about SharePoint 2013 i don't get control over view? Commented Sep 22, 2014 at 8:43
  • SharePoint 2013 has given us a property JSlink to modify our view as we need to do so. But in that case you to written a bit javascript decorating your view in html and giving link to document as anchor tag with '_blank' property. Else than I think, xslt is the only way with SharePoint designer
    – ateet
    Commented Sep 22, 2014 at 8:49
  • not getting the exact property to place "_blank". let me know if you have any Commented Sep 22, 2014 at 9:06
  • Do one thing instead of that, go to document library settings page> Advanced settings>Opening Document in Browser>Choose-Open in client application
    – ateet
    Commented Sep 22, 2014 at 9:59
  • yes tried it, it doesn't work Commented Sep 22, 2014 at 10:00

This is a web app wide setting or a doc lib specific etting. In Central Admin (or through Powershell), change file handling for a web application:


$web  = Get-SPWeb http://yourspweburl
#Get Document Library
$docLib = $web.lists["Your Document Library Title"]
#If you need to change it from Strict to Permissive
$docLib.BrowserFileHandling = "Permissive"
  • Please don't add the exact same answer to this question, as you did on this one. Instead, try to specify your answer further to make it a better of this specific question. Thank You!
    – Benny Skogberg
    Commented Feb 16, 2016 at 20:11

Your Answer

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

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