Home > jQuery, SharePoint, SharePoint 2013, SharePoint Online > SharePoint 2013 – Document Library – Download a copy button

SharePoint 2013 – Document Library – Download a copy button

I found a question in technet forum, the user was asking on How to add “DOWNLOAD A COPY” button in document library COLUMN?

And to answer this question, I did a bit of research and came up with below solution

First step is to add a new column to the document library. I named it as “Download a copy”


Ensure to add the new column as the last column in the View.

Now go back to the view, then edit page. Now add a new Script Editor webpart and paste below code

<script type="text/javascript">
function runAfterEverythingElse(){
var elementArray = document.getElementsByClassName("ms-vb-lastCell");
var idArray = document.getElementsByClassName("ms-listlink");
for(var i = 0; i < elementArray.length; i++)
	elementArray[i].innerHTML = '<a unselectable="on" href="javascript:;" onclick="window.open(\''+ idArray[i]['href'] + '\')" class="ms-cui-ctl-large " aria-describedby="Ribbon.Documents.Copies.Download_ToolTip" mscui:controltype="Button" role="button" id="Ribbon.Documents.Copies.Download-Large"><span unselectable="on" class="ms-cui-ctl-largeIconContainer"><span unselectable="on" class=" ms-cui-img-32by32 ms-cui-img-cont-float"><img unselectable="on" alt="" src="/_layouts/15/1033/images/formatmap32x32.png?rev=31" style="top: -409px; left: -35px;"></span></span><span unselectable="on" class="ms-cui-ctl-largelabel">Download a<br>Copy</span></a>';

Click Ok, and stop editing the page. Final result


  1. TheTseik
    December 11, 2013 at 6:56 PM

    How about sharepoint 2010?

    • A.m.a.L Hashim
      December 11, 2013 at 6:57 PM

      Its not tested in 2010. But I believe you are use the same approach.

  2. TheTseik
    December 12, 2013 at 7:17 PM

    Okey, thanks for the answer. I`ll give it a try.

  3. sagar
    January 6, 2014 at 3:57 PM

    how to give access for this dwonlaod button to specific user?means for user A its able to download but should nt do for user B.

  4. Charlotte tang
    February 12, 2014 at 11:17 PM

    Hi Amal Hashim,

    Thank you so much for sharing the brilliant code.

    In the document list, I have different folders. Inside the folders I have multiple files.

    I would just like the Download a Copy button to appear right next to the files only (not the folder). Is there a way for me to do so?

    Thank you so much in advance for your kind response.

    Charlotte Tang

  5. Chris
    April 8, 2014 at 7:05 PM

    Hey, I cant seem to get this to work. could you help please? It just doesn’t display anything in the column. Defiantly adding the snippet on the right page(allitems.aspx), but I noticed that I have a lot of columns that cant be unselected (width etc) in the view that may be causing an issue – though I made sure Download a copy was still the last column.

    Any advice would be much appreciated, cheers

  6. sandeep
    August 29, 2014 at 6:52 PM

    1 . Do we have a way to download a folder from document library using java script??
    2. Is there anyway to create a button on the sharepoint document library page and on click of that button it should download all the documents from the document library??

  7. October 8, 2014 at 1:04 AM

    This doesn’t work with views that have folders. I was hoping to use this as users drill down in the folders to the actual files, but no luck.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: