none
Open Attachement XSL to a new window? RRS feed

  • Question

  • Hello and thank you in advance!

    I am currently displaying the attachment link in a new column I created in SharePoint designer. I used this article to accomplish this output.

    However, the code opens the link in the same window. How can I alter the XSL to open the attachment in a new window? Any help would be greatly appreciated. Thanks!

    <td id="ItemAttchment{generate-id()}" class="ms-vb"><xsl:element name="SharePoint:AttachmentsField">
    	<xsl:attribute name="runat">server</xsl:attribute>
    	<xsl:attribute name="FieldName">Attachments</xsl:attribute>
    	<xsl:attribute name="ControlMode">Display</xsl:attribute>
    	<xsl:attribute name="Visible">true</xsl:attribute>
    <xsl:attribute name="ItemId"> <xsl:value-of select="@ID" /> </xsl:attribute>
    </xsl:element></td>
    

    Regards,

    Adam

    Friday, March 3, 2017 10:34 PM

Answers

  • Change the following line:

     $("table#idAttachmentsTable a").mousedown(function () {

    with 

     $("#idAttachmentsTable a").mousedown(function () {



    Avijit Sur

    • Marked as answer by AdamDoubleYou Monday, March 6, 2017 7:00 PM
    Monday, March 6, 2017 5:39 PM

All replies

  • Use the following script within your XSL or in a separate script editor webpart:

    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
                    $("table#idAttachmentsTable a").mousedown(function () {
                    var url=$(this).attr('href');
                    window.open(url);
    });
    });
    </script>


    Avijit Sur

    Saturday, March 4, 2017 12:33 PM
  • Thanks for the reply, Avijit.

    However, this code is not working. I confirmed the html elements exist and the code is executing, but to no avail. Will this work for PDFs? PDFs are the primary file types for the application.

    Also, could an IE setting be preventing this?

    Thanks again!

    Adam

     
    Monday, March 6, 2017 5:28 PM
  • Change the following line:

     $("table#idAttachmentsTable a").mousedown(function () {

    with 

     $("#idAttachmentsTable a").mousedown(function () {



    Avijit Sur

    • Marked as answer by AdamDoubleYou Monday, March 6, 2017 7:00 PM
    Monday, March 6, 2017 5:39 PM
  • Thank you Avijit, that worked.

    best regards,

    Adam

    Monday, March 6, 2017 7:00 PM