locked
how to open Sharepoint document Library PDF file in New window

    Question

  • Dear All,

    I have created Shared document library and uploaded PDF files in it. when I am opening the PDF file its opening in the same browser. I want that PDF file should open in new window.

    please suggest me the solution.

     

     

    • Moved by Mike Walsh FIN Monday, August 24, 2009 1:09 PM admin q (From:SharePoint - Design and Customization)
    Monday, August 24, 2009 12:03 PM

Answers

  • Isn't the link John Timney suggested works? (to modify the ONET.XML)?

    http://www.jjfblog.com/2006/12/one-issue-that-came-up-during-recent.html

    Else than that, I suggest you add some Javascript on the page to modify all the links on the page. Try to add a new "Content Editor WebPart" on the page then add the following code :

    <script language="javascript" type="text/javascript">
    
    _spBodyOnLoadFunctionNames.push("SetTargetBlank('/InsertListNameHere/')"); function SetTargetBlank(ToFindInLink) { // Get the collection of <a> tags var aAllLinks = document.getElementsByTagName('a'); // For each <a> tags, for(var i=0;i<aAllLinks.length;i++) { var oA = aAllLinks[i]; var sHREF = oA.attributes["href"].value.toLowerCase(); // If href value contains paramter if(sHREF.indexOf(ToFindInLink.toLowerCase()) > 0) oA.attributes["target"].value = "_blank"; } } </script>
    After, replace the "InsertListNameHere" by your list name and try it... Make sure it doesn't affect other links on the page though.  If yes add some verification before modifying the <A> tag.

    Regards,

    Daniel


    Tuesday, August 25, 2009 11:58 AM

All replies

  • Moving to Admin.
    WSS FAQ sites: http://wssv2faq.mindsharp.com and http://wssv3faq.mindsharp.com
    Total list of WSS 3.0 / MOSS 2007 Books (including foreign language) http://wssv3faq.mindsharp.com/Lists/v3%20WSS%20FAQ/V%20Books.aspx
    Monday, August 24, 2009 1:09 PM
  • There's not a tickbox way of doing this, but there is a blog you should take a look at that will tell you what to do, and what to expect.

    http://www.jjfblog.com/2006/12/one-issue-that-came-up-during-recent.html

    You could of course instruct your users to press control before clicking the hyperlink - think that does it :)

    Regards

    John Timney (MVP)
    Monday, August 24, 2009 2:29 PM
  • Well there is an option in Adobe Reader that disables opening PDF Files in a browser (And I personally think its a good idea to disable that).

    In Adobe Reader 9 :

    - Edit - Preferences
    - Category : Internet
    - Uncheck the "Display PDF in browser "

    But unfortunately you need to do that on every client computers.
    • Proposed as answer by Ivan SandersMVP Tuesday, August 25, 2009 12:21 AM
    • Unproposed as answer by Mike Walsh FIN Wednesday, April 28, 2010 4:28 PM
    Monday, August 24, 2009 3:02 PM
  • hi,

    Thanks for your reply. please suggest me to work around of MOSS. according audit purpose we are not supposed to follow this solution.

    Thanks & Regards,
    Krishna rao. Maturi
    Tuesday, August 25, 2009 10:13 AM
  • hi,

    Thanks for your reply. I am not able to find the solution for this. please suggest the solution for this.

    Thanks in Advance,
    Krishna Rao. Maturi
    Tuesday, August 25, 2009 10:16 AM
  • Isn't the link John Timney suggested works? (to modify the ONET.XML)?

    http://www.jjfblog.com/2006/12/one-issue-that-came-up-during-recent.html

    Else than that, I suggest you add some Javascript on the page to modify all the links on the page. Try to add a new "Content Editor WebPart" on the page then add the following code :

    <script language="javascript" type="text/javascript">
    
    _spBodyOnLoadFunctionNames.push("SetTargetBlank('/InsertListNameHere/')"); function SetTargetBlank(ToFindInLink) { // Get the collection of <a> tags var aAllLinks = document.getElementsByTagName('a'); // For each <a> tags, for(var i=0;i<aAllLinks.length;i++) { var oA = aAllLinks[i]; var sHREF = oA.attributes["href"].value.toLowerCase(); // If href value contains paramter if(sHREF.indexOf(ToFindInLink.toLowerCase()) > 0) oA.attributes["target"].value = "_blank"; } } </script>
    After, replace the "InsertListNameHere" by your list name and try it... Make sure it doesn't affect other links on the page though.  If yes add some verification before modifying the <A> tag.

    Regards,

    Daniel


    Tuesday, August 25, 2009 11:58 AM
  • Hi,

    We have done it this in another way. In designer we converted this document library web part to XSLT data view and changed the javascript for opening document. But in dropdownlist of Name some options are missing (like Manage Permissions, Work flow, Version history etc.). how can I get back those options with satisfieng my requirements.

    Thanks in Advance,
    Krishna Rao. Maturi

    Wednesday, August 26, 2009 8:50 AM
  • has anyone worked this out yet?

    The PDFs need to open in a new window or a new tab, because my users often open a PDF, then close it, but that then kills their sharepoint window (as they didnt hit Back) and then have to navigate around the sharepoint site again to get back to where they were!

    thanks

    Wednesday, April 28, 2010 3:52 PM
  • Users closing rather than choosing back is a user education problem rather than a technology one.  You need to educate them.

    If you open it in a TAB, and force the underlying code to do that then you'll also need to work out what to do when someone isn't using a tabbed browser, so you'll need to create some quite complex javascript I expect.  There is usually a good reason why Sharepoint doesn't do something but the answers above should get you in a  position to accomplish what you would like to do.

     

    Regards

     

    John Timney

    Thursday, April 29, 2010 8:24 AM
  • Hi,

    Javascript can be used to open PDF files in new window. More information:

    http://www.codeproject.com/KB/scripting/pdf-javascript.aspx

    Regards.

    Friday, April 30, 2010 9:30 AM
  • for Moss: http://www.sharepointkings.com/2008/07/open-documents-in-new-window.html

     

    hope this help

    thanks

    -ws


    SharePoint administrator, MCTS,MCITP
    • Edited by Mike Walsh FIN Thursday, March 10, 2011 9:28 PM SP 2010 answer removed off-topic
    Wednesday, October 13, 2010 3:31 PM