Open PDF's in new window in document library when using "Find a file" search

I need to be able to open PDF's in a new window from a document library when using the "Find a file" search built into the document library "All documents" view. I currently have the following javascript on the page:
_spBodyOnLoadFunctionNames.push("setTargetBlank()");
function setTargetBlank()
{ $("a[href$='.pdf']").removeAttr('onclick').attr("target", "_blank");
This works great when going to the document library and navigating through the folders then clicking on a link.
The problem is when someone goes to the document library then uses the "Find a file" search and then they click on a link. The "Find a file" search does not do a postback (reload) of the page, therefore my javascript to find the PDF links
and make them open in a new window does not run for the links on the page.
I have read the following article but this does not seem to offer a solution that will work in this situation for SharePoint 2013 (Office 365): http://social.technet.microsoft.com/Forums/sharepoint/en-US/7ad3224c-3165-47ae-95bc-4f3928e2f9a8/opening-document-library-pdf-in-a-new-window-sharepoint-2013?forum=sharepointgeneral
I suppose the idea solution would be to somehow tap into the event that is fired when using "Find a file" search to run my javascript and update the links for the search results.
Can anyone offer any solutions to this issue?

Hi,
According to your description, my understanding is that you want to open PDF files in a new window from a document library when using the "Find a file" search.
As you said, the "Find a file" search does not do a postback (reload) of the page, therefore JavaScript to find the PDF links and make them open in a new window does not run for the links on the page.
I recommend to use JS link to achieve the goal. Create a JavaScript override file and upload the JavaScript file to the Master Page Gallery, and then set the JS Link property of the document library web part to point to the JavaScript file.
Here are some links about the JS link in SharePoint 2013 for you to take a look:
http://www.idubbs.com/blog/2012/js-link-for-sharepoint-2013-web-partsa-quick-functional-primer/
http://www.learningsharepoint.com/2013/04/13/sharepoint-2013-js-link-tutorial/
http://zimmergren.net/technical/sp-2013-using-the-spfield-jslink-property-to-change-the-way-your-field-is-rendered-in-sharepoint-2013
Thanks,
Victoria
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Victoria Xia
TechNet Community Support

Similar Messages

  • Opening PDFs in a New Window

    Is there a good way to code a link to a PDF on a web page that would ensure that the PDF opens in Reader or in a new browser window/tab instead of in the same window/tab?
    Even though modern browsers allow users to configure their setup to allow PDFs to be opened within the same browser window (this might even be the default behavior nowadays), I've found that many customers end up closing the entire browser by accident after they finish reading the PDF. Then they have to open the browser back up again, sign in again, and navigate back to where they were. In order to reduce the chance of this happening, and to provide a better customer experience, I would like to force the PDF to open in Reader or in a new window/tab.
    However, when I have tried to do this in the past, I have run into many types of errors based on the different browser/platform/version combos that exist out there. Examples:
    Two browser windows are opened -- one blank and one with the PDF.
    The PDF opens in Reader, but a blank window/tab is also opened.
    The PDF won't close. I have to close the window that spawned it first.
    Many of these errors seem to occur on computers where the user has already set up their computer to not allow PDFs to open in the same window/tab. So that when I do something to force the PDF to open elsewhere, it kind of happens twice.
    Is there a nice, clean way to do this?
    Thanks,
    David Ashleydale

    Welcome to the Apple Discussions. To get the pdf file to open in a new browser window you will need to first upload the pdf file to the server and then create a text or image hyperlink to an external page and use the URL to the pdf file. If you have a MobileMe account and put the pdf file in the Web/Sites folder the URL you would use in the Inspector/Links pane would be:
    http://web.me.com/yourMMe_accountname/filename.pdf
    If you were to add a folder to the Sites folder titled PDFs and put the file in it the link would be:
    http://web.me.com/yourMMe_accountname/PDFs/filename.pdf
    OT

  • Open pdf in a new window or save to desktop -- which?

    When I click on a .pdf link, Firefox downloads the file to my desktop. This is fine. Sometimes, however, I would prefer that Firefox simply open the .pdf document in a new window. How can I control this behavior?

    When I click on a .pdf link, Firefox downloads the file to my desktop. This is fine. Sometimes, however, I would prefer that Firefox simply open the .pdf document in a new window. How can I control this behavior?

  • Open PDF Link in new window?

    I want to create a Word document with hyperlinks to a variety of PDF files. I then want to create a PDF file from the Word document with hyperlinks intact.
    Here’s the problem. The PDF file made from the Word document has its embedded links opening in the same window. I want the embedded links to open in a new window. I set up the links in the Word document to open in a new window, but when the Word document is converted to PDF, the embedded links lose their open-in-new-window property.
    I know I can manually set the user preferences in Adobe Reader to not open cross-document links in same window, but that’s not the default.
    Is there a script that can be run when the first PDF file is opened that automatically changes the user preferences so cross-document links open in a new window? Or is there a way to easily modify the links created during the Word-to-PDF process so that the cross-document links open in a new window?
    Thanks for any help.
    JBrush

    I stumbled across this while trying to do a very simple project (or so I thought).  I also wanted my links
    to other pdf files to open in a seperate Adobe window (not a browser window).  I can't seem to get it to work.
    I tried right-clicking and selecting open in new window - didn't work.  I downloaded AutoBookmark as well.  It still didn't open in a new window after setting the option to do so for all links.
    Any suggestions?

  • Open PDF in a new window

    Hi. I'm trying to create a PDF and open it in a new browser window. I've already achieved to create the PDF and it seems to work fine when it opens in the current browser window but that's not what we are looking for.
    This is the code where I call the open report method:
    <h:commandLink id="informe" target="report"
                 onclick="openReport();"
              action="#{listadoPDSBean.mostrarInforme}"
              styleClass="boton"
              value="Ver Informe"/>Here is the javascript method where I open the new window (and about:blank window).
    function openReport() {
              nuevaVentana = window.open("about:blank", "report", "type=window, fullscreen=no, Menubar=no,
                    Status=no, Titlebar=no, Toolbar=no, Location=no, Directories=no, Resizable=yes");
    }When I try this it opens a new blank window and then opens the report in the application window.
    I'm sorry for my bad english.
    Thanks!

    Thanks, Alf.redo. That's what I'm doing now (I think). I have a commandLink that calls a method that writes the PDF. Here is:
    public void doGenerarReport(List listaInstancias, Map parametros,
                   String nombreReport, String formato) throws JRException,
                   IOException, URISyntaxException {
              // Obtener DataSource de la lista dada
              JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(
                        listaInstancias);
              HttpServletResponse response = FacesUtils.getResponse();
              response.setHeader("Content-Disposition", "inline; filename="
                        + nombreReport + ".pdf");
              ServletOutputStream out = response.getOutputStream();
              // Se obtiene el .jasper, el report compilado
              JasperReport report = getJasperReport("es/jda/cma/mrvca/reports/"
                        + nombreReport + ".jrxml");
              JasperPrint jasperPrint;
              try {
                   jasperPrint = JasperFillManager.fillReport(report, parametros, ds);
              } catch (RuntimeException e) {
                   log.error("Error rellenando el report " + nombreReport, e);
                   throw e;
              // Tratamos las caracter�sticas espec�ficas de cada uno de los formatos
              JRAbstractExporter exporter = null;
              if (formato.equals(PDF)) {
                   exporter = new JRPdfExporter();
              } else if (formato.equals(HTML)) {
                   response.setContentType("text/html");
                   exporter = new JRHtmlExporter();
                   exporter.setParameter(
                             JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, false);
              } else if (formato.equals(EXCEL)) {
                   response.setContentType("application/vnd.ms-excel");
                   exporter = new JRXlsExporter();
                   exporter.setParameter(
                             JRXlsExporterParameter.IS_AUTO_DETECT_CELL_TYPE, true);
              } else {
                   log.error("Error exportando el report el formato : " + formato
                             + " no se reconoce. Los formatos reconocidos son " + PDF
                             + ", " + HTML + " y " + EXCEL + " ");
              try {
                   exporter
                             .setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
                   exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out);
                   exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING,
                             "ISO-8859-15");
                   exporter.exportReport();
              } catch (RuntimeException e) {
                   log.error("Error exportando el report " + nombreReport, e);
                   throw e;
              out.flush();
              out.close();
              // Le indicamos a JSF que no queda nada por hacer.
              FacesContext.getCurrentInstance().responseComplete();
         }I try to open a new window with javascript. The new blank window opens in fact (when I create it with window.open. Just target="_blnak" doesn't work) but I cannot put the PDF inside of it. The PDF just opens in the current window not in the new one.

  • HYPERLINKS  is it possible to use "_blank" to open PDF links in new window?

    When I export my PDF from Numbers '08, is it possible to have my Hyperlinks open in a new window? Possibly using the "_blank" HTML function inside the URL dialog? Right now the links just replace the PDF.
    *I've tried ex)*
    http://www.website.com target="_blank"
    http://www.website.com, target="_blank"
    Those don't seem to work. Any ideas? Is this fixed in '09?
    Thanks
    PS - seems there should be a checkbox saying "open hyperlink in new window". Just makes sense.

    Yes, true. But there is a way (in HTML) to force a link to open in a new window by including the "target=_blank" command. I'm wondering if Apple (or anyone else) has found a way to embed this into the "Hyperlink" property within Numbers? If not, it would be nice if future versions had a check box to include this option with a link in the Hyperlink property inspector.
    Thanks for the feedback!
    Message was edited by: flashburn3030

  • How to open a hyperlink in new tab from document library

    hi,
    I have created a Document library programmatically.
    Added values to columns programmatically. One of the column contains a hyperlink.
    I need to open a new tab when a user click on that link?
    How can we do it?
    i cant add CEWP cause there may be libraries above 200 so i cant add CEWP in every lib.
    can we make it programmatically or any library seetings?

    <script src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
    <script>
    $(function() {
    $('a').filter(function() {
    return this.hostname && this.hostname !== location.hostname;
    }).attr('target','_blank');
    </script>
    Place the above script in the master page.So that it is applicable for all the libraries.
    Find other solutions @:
    http://www.sharepointdiary.com/2011/02/sharepoint-link-list-open-in-new-window_21.html#ixzz2I939sGDr

  • Document library: When to rename a file

    Hello,
    In a document library, I need to rename every file inserted there. For example, the file aa.docx should be renamed in 2014-03-04-aaa.docx. I don't mind doing that before or after the popup window comes with the file's properties.
    What should be the best approarch? 
    Thank you
    Christos

    If you can do it, I prefer before. At any rate, you should make very clear that you're changing the file name so the person responsible for inserting documents is aware that it's happenin. Doing it before filling in file properties gives a chance to ensure
    the end user is aware of the name change, which makes the functionality more predictable.
    Kind regards,
    Margriet Bruggeman
    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com

  • No email attachments to Document library when using data driven subscriptions

    We have recently migrated to SharePoint 2013 and setup document libraries to publish reports to.
    When we send an email with an attachment to the document library from a users mailbox, the document library acts as expected and detaches the email and publishes it to a subfolder inside the library. However when we schedule reports using data driven subscriptions
    and add the email address as a CC, the subfolder gets created but there is no attachment.
    What could cause this issue?
    Thanks for your time

    Hi WFN_Will,
    regarding this issue, we don't know for sure, unless we trace the process,
    do the attachment is not there, or when the attachment there the process was failed, or the target not able to receive the attachment?
    from the description, seems the target and the process of receiving the attachment is ok, I guess you can start to check from this part:
    https://sharepointstuff.codeplex.com/workitem/2894
    http://msdn.microsoft.com/en-us/library/ms154050.aspx
    http://technet.microsoft.com/en-us/library/ms159150.aspx
    http://technet.microsoft.com/en-us/library/cc262947.aspx
    http://manomangaldas.blogspot.in/2008/04/send-email-with-attachments-in.html
    to ensure that the attachment is there.
    Regards,
    Aries
    Microsoft Online Community Support
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • Save Target As in IE Opens PDF in a New Window Instead of Downloading

    I work in the IT department at a UK firm of solicitors and we have recently observed issues with using "Save Target As" in Internet Explorer 8 on Windows 7 with Reader XI. Instead of prompting for the path to save the file, as you would expect, it instead opens a new browser window and loads the Adobe Reader plugin to display the file. The download Window does appear but as it doesn't even get as far as prompting for a path to save to obviously it never starts.
    We are able to work around this by clicking the Save button in the Reader plug-in once it has loaded but this isn't practical especially for large or complex documents which may take more than a few seconds to load. The issue does not occur in XP with identical versions of IE and Reader.
    Is anyone aware of a way I can selectively disable this behaviour without disabling the browser plugin as a whole?

    Does that only happen with PDF files, or any files?  My guess is the latter, which indicates a problem with IE.  Try a repair: http://support.microsoft.com/kb/318378

  • Java or HTML to open PDF in a new window in Adobe Reader, not IE

    Good morning,
    We have an interactive PDF document that has Flash built in.  We sized to match the screen settings within our company. However, the way we have it posted, when a user clicks the link to open the PDF document, it opens inside of Internet Explorer.  The IE browser and button bar take up space we need for the document so users don't have to scroll.  What I would really like is to be able to have the user click the link and it opens the document in Adobe Reader instead of IE.  Is there a way to do this?
    Any help would be greatly appreciated.
    Eric

    You need an HTML forum, such as Dreamweaver, to figure out the parameters you use to open the file
    Your question has nothing to do (that I can see) with Acrobat or even Reader (which is a different forum anyway) and everything to do with the HTML commands your web designer needs to use when the file link is clicked from a browser

  • Unable to mail-enable a document library when using Directory Management Service in SharePoint 2013

    I'm not able to mail-enable a library document while Directory Management Service is enabled. This behavior only happens when Directory Management Service is turned on.
    Correlation ID: a8c7b29c-d193-90b5-ae14-64cd1143445f
    Note that I have the OU created and permissions setup properly according to MS official documentation.

    Hi,
    According to your post, my understanding is that you failed to mail-enable a library document while Directory Management Service is enabled.
    Please make sure you configure the incoming email correctly.
    For more information, you can refer to:
    https://hosting.intermedia.net/support/kb/default.asp?id=2439
    http://davecoleman146.com/2010/10/20/how-to-setup-mail-enabled-document-libraries-in-sharepoint-2010-part-1/
    If so and the error message persists, please check the SharePoint ULS log to find more information about this error, the ULS log file is in the location: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\LOGS
    You can check the ULS log by the methods here:
    http://blog.credera.com/technology-insights/microsoft-solutions/troubleshooting-sharepoint-errors/
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Pdf showed in new window. Help needed!

    Hi all,
    This is my first post (but a thousand read), and i want first to thank you all for all the information i have read in this forums for years.
    I have a problem which is giving me more problems that i expected. In my webapp, i want to show a pdf document in a new page of the navigator when a button is pressed. I have discarded the target blank option in the container form because i have others buttons and dont want them to be opened in new windows, just the one that open the pdf.
    So, I used another navigation rule to open a new window. This page have to make de pdf in code an send it to the client. I dont know how to execute that code on the load of the page.
    The solution i am trying is using a poll that only will be called once and in the pollListener execute that code. The problem is that does not work to send the response to the client in the client. Here is the code of the pollListener:
    byte[] file; //Don't worry about it. Contains the file pdf i want to show.
    FacesContext fctx = FacesContext.getCurrentInstance();
    HttpServletResponse response =
    (HttpServletResponse) fctx.getExternalContext().getResponse();
    response.setContentType("application/pdf");
    response.setHeader("Content-Disposition",
    "inline; filename=\"file.pdf\"");
    response.setHeader("Cache-Control", "no-cache");
    response.setContentLength(file.length);
    ServletOutputStream sos = response.getOutputStream();
    sos.write(fichero);
    sos.flush();
    sos.close();
    fctx.responseComplete();
    The curious thing is that if i change the content-disposition to atachemement instead inline, it works asking me to download the file, however, i want it to open directly in the new window and is because of that i use content-disposition inline.
    I am almost killing myself because of this problem. Anyone can help me?
    Thanks in advance!

    First of all, you don't need to do this with a workaround using a Poll listener. I assume that one page has a commandButton or commandLink that is used to show the PDF, right?
    Set the useWindow property of the button or link to "true".
    Set the actionListener property of the button or link to a method in a backing bean that looks something like this:
        public void showPDF(ActionEvent actionEvent) throws IOException {
            //Setup the output
            String contentType = "application/pdf";
            FacesContext fc = FacesContext.getCurrentInstance();
            HttpServletResponse response =
                (HttpServletResponse)fc.getExternalContext().getResponse();
            /* Notice that I don't set the Content-Disposition header - inline is default. */
            response.setContentType(contentType);
            ServletOuputStream out = response.getOutputStream();
            /*  Do whatever you need to do to write the pdf to "out" here. */       
            out.flush();
            out.close();
            fc.responseComplete();
        }

  • Display pdf in a new Window in a JSPDynPage

    I need to display the pdf in a new window on click of a button in the iview. The pdf is fetched as an array of bytes from an RFC. It displays correctly, but in the same window. Pls see the extract of the code:
    To Write
    writeText(IPortalComponentRequest request, IPortalComponentResponse response, byte[] pdfResult)
    try{
    Document doc = new Document(PageSize.A4);
    javax.servlet.http.HttpServletResponse myResponse = request.getServletResponse(true);
    myResponse.setHeader ("ContentDisposition", "inline;filename=\"ShortCV.pdf\"");
    myResponse.setContentType("application/pdf");
    OutputStream os = myResponse.getOutputStream();
    os.write(pdfResult);
    PdfWriter.getInstance(doc,os);
    catch(Exception Ex){
    OnView(Event evt){
    JCO.Field Table1 = m_function.getExportParameterList().getField("PDF_STRING");
    client.execute(m_function);
    writeText(request, response, Table1.getByteArray());
    onView is called on
    Button myButton11 = new Button("myButton11");
    myButton11.setText("View");
    myButton11.setOnClick("View");
    myButton11.render(rendererContext);
    Pls advice

    Detlev .....
    I am still not able to implement your suggested solution.
    If I call javascript written in JSP, will I be able to pass a bean to it. Pls see the code that I hv in addition to the one posted ...
    In ICellRenderer ....
    if ( column == 11 )
    Button myButton11 = new Button("myButton11");
    myButton11.setText("View");
    myButton11.setOnClientClick("Test("beantv2")");
    In JSP
    <script>
    function Test(zBean)
    popAssetWinSpecs = "left=250,top=250,width=300,height=300,scrollbars=no,toolbar=no,menubar=no,resizable=no,status=no,titlebar=no,location=no";
    htmlfile="/irj/servlet/prt/portal/prtroot/AIPLetters.HersheyTeamViewerAIPPDF?zBean="+zBean;
    window.open(htmlfile,"editWindow",popAssetWinSpecs);
    return false;
    </script>
    in the doInitialization of the second comp
    IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
    IPortalComponentContext compcontext = request.getComponentContext();
    AIPBean = new HersheyTeamViewerAIPBean();
    HttpServletRequest zHttpRequest = request.getServletRequest();
    AIPBean = (HersheyTeamViewerAIPBean)zHttpRequest.getAttribute("zBean");
    nothing gets executed ....
    I am not sure whether I am passing the bean correctly
    Thanks for your help,
    Devina

  • Open Sub Report in New Window

    Hi,
    We have an application which is integrated with crystal reports.
    So when you open a report from the application it opens up in a new window. (Ours is a web based application and crystal reports opens up in IE browser)
    We have some reports which have subreports (on demand ), is there any crystal report configuration through which these subreports can be opened in a new window, as of now they open in the same main report window.
    Thanks in advance

    hello,
    you may wish to look into saving the subreport as a separate report and then:
    1) calling the report via opendocument (if your app sits on top of businessobjects enterprise or crystal reports server)
    2) calling the report via URL reporting if your app does not utilize the above platforms
    i can't guarantee the above will work as it may depend on your environment that you are hosting the reports in.
    see the help guide [here |http://help.sap.com/businessobject/product_guides/boexir31/en/xi3-1_url_reporting_opendocument_en.pdf]for more information on linking
    http://help.sap.com/businessobject/product_guides/boexir31/en/xi3-1_url_reporting_opendocument_en.pdf
    as per using a subreport and opening in a new window, this doesn't really work.
    if you want though, you can use a Report Part link to go from the open subreport back to the main report. please see more on Report Part linking in your crystal report's online help.
    jw

Maybe you are looking for