Download a copy button in Document Library - SP2013
One of my Client asked to download a Document , All Users don't have permission to access Ribbon and download a copy of Document, so it this way we can create button for Download a copy of Document
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
1
2
3
4
5
6
7
8
9
10
11
| <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>';} }_spBodyOnLoadFunctionNames.push("runAfterEverythingElse"); </script> |
Click Ok, and stop editing the page. Final result

Genial! it's works fine
ReplyDeleteThank you for sharing.